DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Themeable Views In Ruby

04.23.2005
| 4795 views |
  • submit to reddit
        
class ApplicationController < ActionController::Base
  before_filter :choose_theme
  
  private
  def choose_theme
    ActionController::Base.template_root = File.join(RAILS_ROOT, 'app/views', @params['theme'])
  end
end
    

Comments

Snippets Manager replied on Mon, 2007/04/30 - 4:15pm

oh, i'm sorry! already found the solution by browsing your snippets :) thanks!

Snippets Manager replied on Mon, 2007/04/30 - 4:15pm

I need different paths for layouts based on request.host field. For somesite.com it should be "app/views" and for m.somesite.com "app/mobile_views". Is it possible to do so?