What does :this means in Ruby on Rails?
- by Marco
Hi,
I'm new to the Ruby and Ruby on Rails world. I've read some guides, but i've some trouble with the following syntax.
I think that the usage of :condition syntax is used in Ruby to define a class attribute with some kind of accessor, like:
class Sample
attr_accessor :condition
end
that implicitly declares the getter and setter for the "condition" property.
While i was looking at some Rails sample code, i found the following examples that i don't fully understand.
For example:
@post = Post.find(params[:id])
Why it's accessing the id attribute with this syntax, instead of:
@post = Post.find(params[id])
Or, for example:
@posts = Post.find(:all)
Is :all a constant here? If not, what does this code really means? If yes, why the following is not used:
@posts = Post.find(ALL)
Thanks