Jason Swett
Jason Swett

Reputation: 45084

Different layout for just one certain page in Rails

I want to have a different layout for just one certain action in my Rails app. How do I do that?

Upvotes: 9

Views: 9460

Answers (3)

chief
chief

Reputation: 134

 layout :resolve_layout

  .
  .
  .
     private   
      def resolve_layout
       case action_name
         when "new"
          "alternate"
         else 
          "application"
         end
      end

Upvotes: 9

Voldy
Voldy

Reputation: 12868

class MyController < ApplicationController
  layout "special", :only => :action

  def action
    #action code
  end
end

Upvotes: 19

ecoologic
ecoologic

Reputation: 10420

# controller that calls the page
def action
  render :layout => 'other'
end

Upvotes: 27

Related Questions