i know application.html.erb is the default for every page .i want to use a different layout when user login .i mean the dashboard after login should be of different layout rather than the default one(application.html.erb).
Create new layout eg app/views/layouts/dunno.html.erb
. Use in controller
class DashboardController < ApplicationController
layout 'dunno'
end
or per action
class DashboardController < ApplicationController
def index
render layout: 'dunno'
end
end
see docs for details
You can do this in application controller, add this code, I am assuming that you are using devise
layout :layout_by_resource
def layout_by_resource
user_signed_in? ? "my_custom_layout" : "application"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With