AGoofin wrote:
> When you render a partial you automagically get an object with the
> same name available in the partial
> 
> For example, render :partial => 'foo' passes the instance variable
> named @foo to  the partial where I can then say: for f in @foo.
> 

How do you know that @foo isn't already available to all the views and 
that writing render(:partial => foo) doesn't have any effect whatsoever 
on whether @foo is available in the partial?


> In your first post you iterate over 'test' but that variable isn't
> created anywhere.
> 

Sure it is.  Try it.  I'm just a beginner but my Dave Heinemeier Hansson 
book says the variable test gets created by the render() statement, and 
my tests confirm that's the way it works.  More generally, when I write

<% render(:partial => "random_name", :object => @var) %>

and @var was assigned a value in the controller, then I find that the 
value of @var gets assigned to the variable "random name", and 
random_name can be accessed in the partial _random_name.html.erb.  In 
addition, my tests show that @var can be accessed in 
_random_name.html.erb as well.  I'm not sure why you would want to stuff 
the value of @var into another variable when you can just access @var 
directly.  Switching the names seems confusing to me.



-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to