There is such a structure:
enter image description here
In _kurators.html.erb I try to render a partial:

 <%= render :partial => 'kurators/simple_list' %> 

In kurators/simple_list I try to call the model method:

 <%= get_issues_by_me %> 

Model kurator.rb :

 class Kurator < ActiveRecord::Base def get_issues_by_me 'test' end end 

I get the error:

 undefined local variable or method `get_issues_by_me' for #<#<Class:0x00000004146988>:0x00000004257278> 

What am I doing wrong?

UPDATE:
kurators_helper.html.erb :

 module KuratorsHelper def kurators_helper_test 'test' end end 
  • And how did you know that get_issues_by_me is a model method in the context of a view? - MAXOPKA
  • I also tried adding the model name <%= Kurator.get_issues_by_me %> , but in this case I get the error: undefined method get_issues_by_me for Kurator(Table doesnt exist):Class . Yes, that's right, I don't have a table, but I don’t need it, I just need to return the data from this method - S.Ivanov
  • Try to declare a method as a class method, not an instance method: def self.get_issues_by_me - MAXOPKA
  • Yes, it worked. And how can I call the helper method from the partial? - S.Ivanov
  • Since helpers are usually included in the context of a view, then simply by a bare name, as you initially mistakenly did for the model. This method does not work for models, but for helpers - quite. - D-side

1 answer 1

 class Kurator < ActiveRecord::Base def self.get_issues_by_me 'test' end end 

And call like this

 <%= Kurator.get_issues_by_me %> 

If you need to call for a specific user, then read about scopes:

http://rusrails.ru/active-record-query-interface#scopes