summaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 62a4e13..240df61 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -3,7 +3,7 @@ class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_locale, :initialize_pages
- if Rails.env == 'production'
+ if Rails.env.production?
rescue_from Exception, :with => :render_500
rescue_from ActionController::RoutingError, :with => :render_404
end
@@ -72,17 +72,18 @@ class ApplicationController < ActionController::Base
# run every time in development mode, run once in production mode
#
def initialize_pages
- run_once(:unless => Rails.env.development?) do
+ run_once(:initialize_pages, :unless => Rails.env.development?) do
StaticPage.load(PAGE_DIRECTORY)
Menu.load(PAGE_DIRECTORY + '/menu.txt')
end
end
- def run_once(options={})
- if !@run_once || !options[:unless]
+ def run_once(name, options={})
+ key_name = "run_once_#{name}"
+ if !Thread.current[key_name] || options[:unless]
yield
end
- @run_once = true
+ Thread.current[key_name] = true
end
end