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?. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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. On May 12, 7:59 am, nirosh <kunalan.kand...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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. > > any clue for this?. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
thanks man thats the right clue now its working -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 12 May 2010 06:59, nirosh <kunalan.kandiah-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.