Reputation: 1101
class UserSignupController < ApplicationController
layout "signup", only: [:signup]
layout "user_sessions", only: [:thanks]
def signup
end
def thanks
end
end
I have two different layouts. I want to call signup layout for signup.It can works fine. But when i give two layouts it crashes my code. Is it possible to give like this?
Upvotes: 2
Views: 229
Reputation: 8220
You can add a method to set the layout and put under private.
class UserSignupController < ApplicationController
layout :specific_layout
def signup
end
def thanks
end
private
def specific_layout
case action_name
when "signup"
"signup"
when "thanks"
"user_sessions"
else
"otherlayout"
end
end
end
Upvotes: 0
Reputation: 4398
You can specify the layout in each action if you want to use separate ones. So for example
def signup
render "signup", layout: "signup"
end
def thanks
render "thanks", layout: "thanks"
end
That should do it :)
Upvotes: 2