diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 22deef5..d363be8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -311,22 +311,35 @@ module ApplicationHelper end def current_theme - return session[:theme] if (session[:theme]) - - # utility for developers: set the theme to 'random' in development mode and - # you will get a different theme every request. This is interesting for - # testing - if ENV['RAILS_ENV'] == 'development' && @environment.theme == 'random' - @theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand - return @theme - end - - p = profile - if p - p.theme - else - @environment.theme - end + @current_theme ||= + begin + if (session[:theme]) + session[:theme] + else + # utility for developers: set the theme to 'random' in development mode and + # you will get a different theme every request. This is interesting for + # testing + if ENV['RAILS_ENV'] == 'development' && environment.theme == 'random' + @random_theme ||= Dir.glob('public/designs/themes/*').map { |f| File.basename(f) }.rand + @random_theme + else + if profile + profile.theme + elsif environment + environment.theme + else + if logger + logger.warn("No environment found. This is weird.") + logger.warn("Request environment: %s" % request.env.inspect) + logger.warn("Request parameters: %s" % params.inspect) + end + + # could not determine the theme, so return the default one + 'default' + end + end + end + end end def theme_include(template) diff --git a/db/schema.rb b/db/schema.rb index 01af210..348caf4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -89,8 +89,8 @@ ActiveRecord::Schema.define(:version => 69) do t.boolean "virtual", :default => false end - add_index "articles_categories", ["article_id"], :name => "index_articles_categories_on_article_id" add_index "articles_categories", ["category_id"], :name => "index_articles_categories_on_category_id" + add_index "articles_categories", ["article_id"], :name => "index_articles_categories_on_article_id" create_table "blocks", :force => true do |t| t.string "title" @@ -131,8 +131,8 @@ ActiveRecord::Schema.define(:version => 69) do t.boolean "virtual", :default => false end - add_index "categories_profiles", ["profile_id"], :name => "index_categories_profiles_on_profile_id" add_index "categories_profiles", ["category_id"], :name => "index_categories_profiles_on_category_id" + add_index "categories_profiles", ["profile_id"], :name => "index_categories_profiles_on_profile_id" create_table "comments", :force => true do |t| t.string "title" @@ -211,8 +211,8 @@ ActiveRecord::Schema.define(:version => 69) do t.datetime "updated_at" end - add_index "product_categorizations", ["product_id"], :name => "index_product_categorizations_on_product_id" add_index "product_categorizations", ["category_id"], :name => "index_product_categorizations_on_category_id" + add_index "product_categorizations", ["product_id"], :name => "index_product_categorizations_on_product_id" create_table "products", :force => true do |t| t.integer "enterprise_id" @@ -284,10 +284,6 @@ ActiveRecord::Schema.define(:version => 69) do t.integer "environment_id" end - create_table "schema_info", :id => false, :force => true do |t| - t.integer "version" - end - create_table "taggings", :force => true do |t| t.integer "tag_id" t.integer "taggable_id" @@ -295,8 +291,8 @@ ActiveRecord::Schema.define(:version => 69) do t.datetime "created_at" end - add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" add_index "taggings", ["taggable_id", "taggable_type"], :name => "index_taggings_on_taggable_id_and_taggable_type" + add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id" create_table "tags", :force => true do |t| t.string "name" -- libgit2 0.21.2