Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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