Ask A Question

Notifications

You’re not receiving notifications from this thread.

Using multiple theme in Multi tenancy application

Oyewole Samuel asked in General

Great work Chris, this my second month in this forum and i really enjoy the series of tuts, please i'm currently working on multi tenancy application that require user to select desired theme. please how can i go about this? Thanks

Reply

I believe you could use layouts and get away with something like this...

#application_controller.rb
class ApplicationController < ActionController::Base
  layout :user_theme

  def user_theme
    current_user.theme
  end
end

Then each layout you could adjust which css files to use.

Depending on your needs and how you have your site setup, I believe you could also just load a themed css file from the <head>... with a <%= stylesheet_link_tag current_user.theme %>

This should get your thinker tinkering - I'm sure there's a better way and I'm not sure what effect the multi-tenancy could have on any of these ideas...!

Reply

Thanks @jacob, thanks so much for your explanation, i've been thinking around that also, i found this gem
https://github.com/yoolk/themes_on_rails,

Do you think this can serve the purpose?. i'm looking at get over 20 templates from themeforest, so, when user want to register on my website, they can select which template they want on there home page. someone like wordpress.

i'm new to ruby on rail, i believe your years of experience can help me achieve this. thanks

Reply

I'd suggest making a branch of your project and just test it out. But from the looks of it, it seems like that gem would help you with the organization of your assets but it doesn't seem like there's any real magic going on there that you couldn't just replicate yourself and would save yourself the overhead of the gem dependency.

Read up on how rails handles layouts and the asset pipeline. Also be sure to watch Chris' video on purchased themes.

Reply
Join the discussion
Create an account Log in

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

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

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