i need to define a custom finction in model which is named as
“count_remaked_users”.
when i try to access that function from view (<
%=User.count_remaked_users%>) i’m getting “undefined method” error.
any clue for this?.
i need to define a custom finction in model which is named as
“count_remaked_users”.
when i try to access that function from view (<
%=User.count_remaked_users%>) i’m getting “undefined method” error.
any clue for this?.
class User < ActiveRecord::Base
def self.count_remade_users
end
end
My guess is that you are missing the “self” part of the method
declaration, which tells ruby that this is a class method.
thanks man thats the right clue
now its working
On 12 May 2010 06:59, nirosh [email protected] wrote:
i need to define a custom finction in model which is named as
“count_remaked_users”.
when i try to access that function from view (<
%=User.count_remaked_users%>) i’m getting “undefined method” error.
I see the problem has been solved, but just to point out that it is
generally considered bad form to call a model method from a view, it
is considered better to set up data in the controller and display it
in the view.
Colin
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs