Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix asset precompile on Cloud Foundry #636
Asset precompile is failing because it tries to initialize the Rails app, which tries to access the DB at initialization time, which fails because the buildpack doesn't pass in the DB connection info at compile time.
@dlapiduz identified the specifics of the Rails initialization problem:
Note on solution 2: Heroku used to have a Labs feature called
@NoahKunin: Oops, sorry for the slow response!
Here is the awful code in question:
See the comments for cause and fix. After the 4 options listed in the issue description, I went for option 5 (paper over the problem while loudly whistling). In practice this solution is probably the best one for the moment; it's cheating, but unlikely to backfire on us.
The ideal one would be option 4: untangle
Does that explain things enough?
Are you sure your asset precompilation is working? I cloned this repo just now and when I try to precompile the assets locally (after setting the proper env vars), it's failing due to a known issue with using
The solution is to add all of the attributes (even non-virtual ones) to
# in app/models/user.rb attr_accessor :just_created, :auto_approve, :terms_of_service, :two_factor_required validates_acceptance_of :terms_of_service ...
# in lib/doorkeeper_patches/models/application.rb attr_accessor :terms_of_service_accepted validates_acceptance_of :terms_of_service_accepted, ...
To test asset precompilation locally, I didn't run
For a more generic test that works whether or not you already have the DB created, you can test by specifying a nonexistent DB, like this:
Initial investigation suggests that the problem is a slightly different (but related) one - the fields in the validations are real, not virtual.
The compilation problem is fixed by adding
Agreed. It was premature of me to suggest using
However, taking a step back, I would question whether
I also noticed that you have 2 similar validations related to terms of service, one in the User model that uses the virtual
You also have another acceptance validation for the database column