Forums » Development »
Difference between using query and @query in views/_list.html.erb
Added by Olivier Houdas almost 9 years ago
Hi,
This is just a curiosity question about programming with Ruby on Rails...
In app/views/_list.html.erb, there are references to @query
, but also to query
.
According to Ruby variable naming, @query
is an instance variable, and query
is a local variable.
query
comes from the call:<%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query} %>
in views/issues/index.html.erb
@query
comes from the issues controller itself
So I was wondering,
1. If we modify query
, will it modify @query
?
2. Why do we want to use the local query
variable for calls to column_header() and to column_content() (queries_helper), which, in principle, should not modify the object?
Thank for helping me fulfill my curiosity :)
Olivier