Reputation: 7041
I would like to display certain things on every or almost every page of my application. Things like header, footer, sidebar or navigation.
How would I go about doing that? I am coming from languages like PHP and ColdFusion where I would either include files or call a function to display what I want. I am having a hard time understanding how I can implement it in Rails.
Upvotes: 0
Views: 108
Reputation: 50057
Generally in your application layout, you use partials. A small example would look like
<body>
<%= render :partial => 'shared/header' %>
<%= yield %>
<%= render :partial => 'shared/footer' %>
</body>
Hope this helps.
Upvotes: 1
Reputation: 19041
Your application should have app/view/layouts/application.html.erb
. That's where your html content goes.
In the application.html.erb, you should see <%= yield %>
. This is where specific views for different controller actions with corresponding views go.
For your css files for application.html.erb, you should use app/assets/stylesheets/application.css
.
For your javascript files for application.html.erb, you should use app/assets/javascripts/application.js
.
Upvotes: 0