Skip to content

Instantly share code, notes, and snippets.

@nicholasf
Created June 16, 2010 01:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicholasf/439980 to your computer and use it in GitHub Desktop.
Save nicholasf/439980 to your computer and use it in GitHub Desktop.
#in development.rb - this avoids the missing constant error which can result on a 2nd and subsequent request
#it can also fix the timezone aware problem expressed at https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1339-arbase-should-not-be-nuking-its-children-just-because-it-lost-interest#ticket-1339-59
#we use this to ensure that the dev environment (with config.cache_classes=false) remembers to load certain classes
#this isn't an issue in production where config.cache_classes=true
class ClassLoader
def initialize(app)
@app = app
end
def call(env)
load 'folder_entry.rb' unless defined? FolderEntry
load 'cms.rb' unless defined? Cms
load 'folder.rb' unless defined? Folder
load 'cms_page.rb' unless defined? CmsPage
load 'article.rb' unless defined? Article
@app.call(env)
end
end
config.middleware.use("ClassLoader")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment