Skip to main content

Change Layout based on current URL

Rails • Asked by Sascha M.

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.

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 20,000+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.