Forum: Ruby on Rails Passing Variables to a sub template

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
612a5333e356c4f765230d9ac06e5c8c?d=identicon&s=25 Pradeep Sethi (psethi2000)
on 2006-04-21 22:54
Hi,

I must be missing something very basic here.

I have a parent template and I am calling a sub template like...

<%= render( :partial => "window_title_bar", {"heading" => "Product
Details"}) %>

and in the sub template (_window_title_bar.rhtml), i am doing

Heading: <%= heading %>

but I am getting syntax error in the master template at line

<%= render( :partial => "window_title_bar", {"heading" => "Requirement
Details"}) %>

Any help is appreciated. Thanks in Advance.

Pradeep
0091f92762685860109bbcb02edfdf27?d=identicon&s=25 Alain Ravet (Guest)
on 2006-04-21 23:23
(Received via mailing list)
Pradeep

     >  render( :partial => "window_title_bar", {"heading" =>
"Requirement  Details"})

You forgot the ':locals  => ' part. It should read:
     >  render( :partial => "window_title_bar", :locals => {"heading" =>
"Requirement  Details"})


See
     http://api.rubyonrails.com/classes/ActionControlle...

Alain
7c4087d053eb02d099a17d91ba5e33b5?d=identicon&s=25 Brian V Hughes (Guest)
on 2006-04-21 23:23
(Received via mailing list)
On Apr 21, 2006, at 04:54 PM, Pradeep Sethi wrote:
> but I am getting syntax error in the master template at line
>
> <%= render( :partial => "window_title_bar", {"heading" => "Requirement
> Details"}) %>

You need to specifically tell the render method that you are passing
in local values for the partial template to use:

<%= render( :partial => "window_title_bar", :locals => {"heading" =>
"Requirement Details"}) %>

I also recommend using symbols whenever you can, so I would actually
use this version:

<%= render( :partial => "window_title_bar", :locals => {:heading =>
"Requirement Details"}) %>


-Brian
This topic is locked and can not be replied to.