Hello all,
Forgive me if this is a really stupid question. How do you render
partials in a layout? It’s probably way easier than i believe it to be.
thanks!
Hello all,
Forgive me if this is a really stupid question. How do you render
partials in a layout? It’s probably way easier than i believe it to be.
thanks!
Jon Mr wrote:
Hello all,
Forgive me if this is a really stupid question. How do you render
partials in a layout? It’s probably way easier than i believe it to be.
thanks!
Hi Jon
Not sure if this is what you need, but you can use
<%= render(:partial => “name_of_partial”) %>
where the name_of_partial is a rhtml file started with ‘_’ for example
_name_of_partial.rhtml
Hope this help
Victor
On 6/22/06, Rohith R. [email protected] wrote:
But remember to include the name of the controller/directory the
partial is
under.
so
<%= render :partial => “mycontroller/my_partial” %>for the partial stored as app/views/mycontroller/_my_partial.rhtml
You only need to specify the controller if the partial is in a different
folder than the layout file that’s calling it.
If you have partials accessed by several controllers, you can put them
in a
separate folder under app/views (ie: “shared”) and call thus:
<%= render :partial => “shared/_my_partial” %>
In other words, they don’t have to be stored in a folder that
corresponds to
a controller name.
Hey Jon
What Jon suggested should work. But remember to include the name of the
controller/directory the partial is under.
so
<%= render :partial => “mycontroller/my_partial” %>
for the partial stored as app/views/mycontroller/_my_partial.rhtml
HTH
~R
There is also the content_for method that allows dynamic content to be
included to a layout. May or may not be helpful to you. Just another
avenue to explore.
http://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#M000528
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs