Ruby on Rails

How to change layouts based on every action in Rails

How to change layouts based on every action in Rails.

We have more than one layouts for individual action and need to change this based on action or page, how to do that.

Very easy, first you can create layouts in layouts folder as like

  • about_layout.html.erb
  • home_layout.html.erb
  • contact_layout.html.erb
  • product_layout.html.erb

now in the controller

This called action base layout.

Fool Dev

I didn't get trained by the school system like other kids, and when I did concentrate on learning, my mind was cluttered and locked by the programming of the system. © Huey Newton