ruby on rails - How do I only display a specific layout for Controller X -


let's want display specific layout when i'm on home page. home page's controller , action home#index.

how display different layout business#new?

there couple of options:

option 1 - specific layout @ controller level

just create layout file named business.html.erb in app/views/layouts , automatically picked rendering views of businesscontroller

option 2 - custom layout name @ controller level

create layout file named my_custom_name.html.erb in app/views/layouts , in controller specify as:

class businesscontroller < applicationcontroller   layout "my_custom_name"   #... end 

my_custom_name layout used views corresponding businesscontroller.

option 3 - layout particular action in controller

create layout file named layout_name.html.erb in app/views/layouts , in controller specify as:

class businesscontroller < applicationcontroller     def new      # ...      render :layout => "layout_name"    end  end 

in case, layout_name layout applied rendering new.html.erb page.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -