Different style sheets for different controllers

What is the best way to use different styling on an app.

I have a style sheet for my login page/signup page that is completely different to the rest of the app.

Thanks

Since your login page is completely different, I would suggest using a separate layout. This layout would load the separate styles and could have different markup.

By default, Rails will look for a layout file under app/views/layouts named the same as you controller (sessions.html.erb for SessionsController). If it doesn’t find one, it will use the application.html.erb template. You could also have a custom layout and call it from the controller as follows:

SessionsController < ApplicationController
  def new
    render :new, layout: 'my_custom_layout'
  end
end

This rails guide is a good read on how rendering works in Rails. It covers custom layouts among other things.

1 Like