diff options
author | elijah <elijah@riseup.net> | 2012-08-25 17:10:16 -0700 |
---|---|---|
committer | elijah <elijah@riseup.net> | 2012-08-25 17:10:16 -0700 |
commit | cb2c6b5ec372e4aa0eee18d7259f43e2239a9244 (patch) | |
tree | 94746b66c3595c31e4461d327a3bab49f26fc495 /app | |
parent | 627f0488e5bd3c31359fc9e78acffbfea4a86a8b (diff) |
fixed run_once. should now be much faster :)
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/application_controller.rb | 11 | ||||
-rw-r--r-- | app/views/pages/about-us/news/2012/first-post/en.haml | 2 |
2 files changed, 7 insertions, 6 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 diff --git a/app/views/pages/about-us/news/2012/first-post/en.haml b/app/views/pages/about-us/news/2012/first-post/en.haml index d32753a..164092c 100644 --- a/app/views/pages/about-us/news/2012/first-post/en.haml +++ b/app/views/pages/about-us/news/2012/first-post/en.haml @@ -1,4 +1,4 @@ -- @title = "Tada! A website" +- @title = "Tada! A website." - @author = "Elijah" - @posted_at = "2012-08-24" - @tags = [''] |