Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Rails Loading Problems #188

merged 3 commits into from May 9, 2012


Copy link

@cookrn cookrn commented May 9, 2012


  • Add app/decorators to Rails eager autoload-ing paths
  • Ensure that our decorators are loaded after every request in development, or at least once at app boot in non-development environments with a to_prepare block

With these changes, users should now be able to call without ever explicitly referencing their decorator constant i.e. ModelDecorator.

( This is in reference to Issue #32 )

Copy link

@travisbot travisbot commented May 9, 2012

This pull request passes (merged 8681058 into b60d195).

# can be loaded.
config.before_initialize do |app|
app.config.paths.add 'app/decorators', :eager_load => true

This comment has been minimized.


steveklabnik May 9, 2012

I guess it's the eager that's the needed part here, since rails loads everything from app. Interesting!

steveklabnik added a commit that referenced this pull request May 9, 2012
@steveklabnik steveklabnik merged commit e2151cd into drapergem:master May 9, 2012
Copy link

@steveklabnik steveklabnik commented May 9, 2012

Thank you! I think this deserves a release, especially with all the other fixes. I'm gonna see if there's anything else I can knock out.

Copy link

@rslifka rslifka commented Jun 14, 2012

Hi guys,

The specific error we're seeing now is that autoloading requires the database to exist when a line like this is present in your models:

scope :using_youtube_video_id, where(player: %w[Youtube])

rake -t db:drop db:create && rake -t db:migrate

  1. Drop/Create complete, migrate started
  2. Full environment loads
  3. Draper eager loads models via decorates method in decorators
  4. The 'where' clause executes in the models (requires the database)
  5. Boom

We can wrap all of our where clauses in lambdas. That doesn't feel quite right though.

What do you think?


Copy link

@steveklabnik steveklabnik commented Jun 14, 2012

@rslifka as that's sorta a different thing, can you file it as a new issue please? Thanks.

Copy link

@rslifka rslifka commented Jun 28, 2012

Hey Steve, will do! Was wary of opening an issue pointing to another issue without first commenting there :) Thanks!

(Apologies for late follow-up. Must have my notification settings off because I'm not getting emails from GitHub.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants