Search code examples
cssruby-on-rails-3footer

Multiple shared footers in Rails 3


Is there a way of rendering different shared footers in rails, so for example i would like one footer for the homepage and then a different footer throughout the site.

has anyone done this before? i was thinking that an if statement would work depending upon the page viewed? not sure if this is correct

Any help appreciated


Solution

  • If you had the following layouts:

    • app/views/layouts/application.html.erb
    • app/views/layouts/home.html.erb

    You'd just specify the layout in your homepage controller as in

    class HomeController < ApplicationController
      layout 'home'
      #everything else follows...
    end
    

    The rest of your views will use the default, which is application.html.erb.