Worker 8
Worker 8

Reputation: 113

Rails - Multiple Layouts Question

I have more than 1 app that are exaclty the same. The only difference is the layout of these apps. I was looking for a way that I could change the layout based on what Iḿ going to use. Example: if I seed my database with male stuff, the app will have to use the male layout. The same happens if I seed with female data.

In my searchs I have found the nested layouts and even some theme generators gens, that I don't think will actually work since I already have the layouts made.

Any one has any new idea?

Thanks in advance.

Upvotes: 0

Views: 340

Answers (1)

bassneck
bassneck

Reputation: 4043

Given you know how to detect what layout to load, something like this should work:

class ApplicationController < ActionController::Base
  layout :choose_layout

  protected
    def choose_layout
      *your male/female logic* ? "male" : "female"
    end

end

rails guides

Upvotes: 3

Related Questions