experimenting, trying to understand local and instance vars and their
relationship to views
I have a controller with an index method.
it sets a local variable like this: (of course I could just make it an
instance variable here but ...)
search_results = Ticket.find(:all, :conditions => session
[:search_conditions]) if session[:search_conditions]
in the index view I say this to show the search results, "result" is
the name of the variable in the partial.
<div id="search_results">
<%= render :partial => ''search_results'', :layout =>
false, :locals =>
{ :result => @search_results } %>
</div>
I''m not explicitly setting search_results as an instance variable
anywhere in the controller. But, just putting the @ in front of the
variable name in the index view seems to auto-magically convert local
variable search_results from the index controller method to an
instance variable usable in the index view.
Is that right? That''s just the way it works in Rails 2.2 ?
--~--~---------~--~----~------------~-------~--~----~
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-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---