But even if I call "Note.get_location(1)", it throws the same error :/
What i'm doing wrong?

simon

On 10 Lip, 18:08, Frederick Cheung <frederick.che...@gmail.com> wrote:
> On Jul 10, 4:22 pm, Szymon Przybył <apocalyp...@gmail.com> wrote:
>
>
>
> > Hi!
>
> > I'm new in Rails and I'm making my first site using this. I have some
> > problem with methods in models:
>
> > I have model Note with one additional method:
>
> > class Note < ActiveRecord::Base
> >   belongs_to :pattern
> >   def get_location(location)
> >     find(:conditions => ["location = ?", location])
> >   end
> > end
>
> > And when I'm trying to access it through
> > pattern.notes.get_location(1) , it throws an error:
>
> > undefined method `get_location' for #<Class:0xb6bc63ec>
>
> get_location is an instance method of Note but you're trying to call
> it on a collection of notes (Because associations are also scopes you
> can call class methods on them: this just calls the class method with
> finds etc scoped appropriately, but I'm not sure if that is what you
> were trying to do).
>
> Fred
>
> Fred
>
> > What i'm doing wrong?
>
> > cheers!
> > Szymon

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to