variables that have @
are instance variables in the scope of the current object.
the variables without @
are local variables in the scope of the current object.
In the specific case of Rails, the variables with @
used in the controllers are made available to be used "inside" the views.
For the each
that was quoted follow the example below:
@posts.each do |post|
<faz alguma coisa com 'post' aqui>
end
In this code snippet, the variable post
is local to the scope of the block in which it was set, so it only exists inside the block do |post| ... end
To better understand the differences between variable types, classes, and objects, take a look at this link link .
About each
, look here link