chamnap / themes_on_rails

Adds multi themes support to your Rails 3/4/5 application
https://rubygems.org/gems/themes_on_rails
MIT License
217 stars 86 forks source link

inline theme proc got error #27

Closed wuwx closed 8 years ago

wuwx commented 9 years ago

i am use rails 4.2.4 my controller code like this

class Sites::ApplicationController < ::ApplicationController
  before_action :set_site
  #theme Proc.new { |controller| @site.theme || 'default' }
  theme Proc.new { |controller| params[:theme].presence || 'professional' }

  private
    def set_site
      @site ||= Site.find(params[:site_id])
    end
end

but got error:

undefined local variable or method `params' for Sites::ApplicationController:Class

chamnap commented 8 years ago

You need to access from controller.

 theme Proc.new { |controller| controller.params[:theme].presence || 'professional' }