Well, I have a “sidebar” in a website that is rendered inside the main
layout. What I want to do is to put the sidebar in a separated file and
then call
= render :partial => “sidebar.html.haml”
Just to have them in separated files.
Where is the convention to put it?
In the root of /app/views?
In /app/views/application?
In /app/views/layout?
In a separated view folder?
“Ruby on Rails 3 Tutorial” puts them in the layouts directory, e.g.
layouts/_sidebar.html.erb, which are then inserted into the application
layout with:
“Ruby on Rails 3 Tutorial” puts them in the layouts directory, e.g.
layouts/_sidebar.html.erb, which are then inserted into the application
layout with:
<% render ‘layouts/sidebar’ %>
That seems rational, since the scaffolding creates a _form element,
thanks ^^
However, when you try to include a partial render from a layout and it
is missing you can see that the paths where it search for the view are
views/application and views/.
So I assume that:
shared partial renders should go into views/applications
controller specific partial renders should go into views/
both should be named with a starting underscore and called without it
however if you wish to render the partial view from another controller
you have to select the path calling render /<partial_view>
At least that’s how I’m going to do from now on ^^
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.