Ask A Question


You’re not receiving notifications from this thread.

Change Layout based on current URL

Sascha M. asked in Rails

Hi all,

let's say I wand to build a whitelabel product.

I want to display different layouts (Logos, CSS, ...) based on the current URL the website was accessed by.

E.G. should render a different layout than

I couldn't find anything describing something like that anywhere :(

Thanks in advance!


As a really trivial example, you can do what they mentioned on StackOverflow here:

  layout :domain_layout

    def domain_layout

Which would look for app/views/layouts/, etc.

You can do other tweaks to that to decide which file to render.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 78,890+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2023 GoRails, LLC. All rights reserved.