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! -- Posted via http://www.ruby-forum.com/.
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 -- Posted via http://www.ruby-forum.com/.
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 On 6/22/06, Victor Fan <victorfan88o-code@yahoo.ca> wrote:> > 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 > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060622/7f51488c/attachment.html
On 6/22/06, Rohith Ravi <entombedvirus@gmail.com> 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. -- "Impossible is nothing." -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060622/1bf11114/attachment.html
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 On 6/23/06, zer0halo <zerohalo@gmail.com> wrote:> > On 6/22/06, Rohith Ravi <entombedvirus@gmail.com> 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. > > -- > "Impossible is nothing." > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060623/aa6bf187/attachment.html