Forum: Ruby on Rails RE: undefined??

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ross D. (Guest)
on 2006-05-12 04:22
(Received via mailing list)
Good to know the reason why.

Ruby has a naming convention where Recipe refers to a class and recipe
is a local variable, that holds a reference to an instance of an object

.find_all is a method of a Class.  You don't need an instance of an
object to reference class methods just the class definition (I know in
Ruby this is not strictly correct because Everything in Ruby is an
object even a Class)

So for example

Recipe.new or Recipe.find_all are methods of the Class

my_recipe.ingredients is a method on an object referenced by the local
variable my_recipe (which from the name is probably an instance of
Recipe).
It could just as easily be @my_recipe.ingredients

HTH

Ross
This topic is locked and can not be replied to.