-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use Railties for initializing plugin #192
Comments
|
@BobWalsh - The plugin works on Heroku but it breaks the asset precompilation stage (for asset pipeline) of deployment which means Heroku has to fall back to dynamically generated assets which are slower. This happens if a plugin attempts to load ActiveRecord during initialization (Rails made some changes to minimise this but acts as taggable is still affected). The reference to ActiveRecord forces the DB connection to be attempted - which fails as Heroku hasn't configured the database connection at that stage of the deployment. If I disable acts as taggable plugin then the assets are precompiled cleanly. |
@smoothcontract pull request is welcome. |
@artemk Fair enough - I'll give it a go when I get some time available |
I'm using a hack to work around the issue with act as taggable until it is fixed. acts_as_taggable rescue nil # HACK: there is a known issue that acts_as_taggable breaks asset precompilation on Heroku. |
+1 on this and |
+1 with the problem (and also the work around, thanks @WizardOfOgz ) |
@dwaynemac I use that in each model that I want to make taggable |
from the Ruby on Rails guides they mention a workaround for the heroku issue with some gems http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets Basically you set config.assets.initialize_on_precompile to false. |
Would this problem be fixed if this plugin is moved to an engine structure? |
+1 With problem (and the workaround is not working on Rails 4.0.0rc1) |
+1 on the problem and the workaround on 4.0.0 |
+1 on this. Just ran into this issue deploying a Rails 4.0 / Ruby 2.0 app onto Heroku. The |
Would it not be better to use Note: I haven't tested this yet; just wondering if someone here has a reason for ruling that out. |
I tried several different combinations of checking if the connection was present/active. Unfortunately this doesn't work: I guess for now I'm justing going to |
Well, I guess we have our answer. Maybe you should post a comment on the acts_as_taggable thread just to keep
|
hey folks, FWIW you can prevent this issue without a blanket rescue nil by doing: |
Thanks! Nicer hack! On Thu, Aug 29, 2013 at 10:35 PM, jack dempsey notifications@github.com
|
Indeed |
@jackdempsey That doesn't work for me as it seems to choke when Heroku does |
@Linuus Just do something like:
|
@adamrubin and @jackdempsey Thanks for posting your updated ways around this, it's been bugging me for the last couple of days! |
unless (ARGV & ['assets:precompile', 'assets:clean']).any?
acts_as_taggable_on :foo
end |
@markburns Thanks for providing a workaround for this problem. |
@rcuyegkeng I can't take credit - I just reworded @adamrubin 's solution |
Should be fixed by #438 |
We use this plugin with Rails 3.1 but due to the way the plugin initializes itself we get an error whilst running the 'rake assets:precompile' task on deployment to Heroku.
Essentially the plugin forces ActiveRecord to be loaded during initialization, which in turn forces a database connection to be attempted. This probably doesn't matter that much when deploying elsewhere but Heroku builds a 'slug' with all the precompiled assets - at which point the database connection isn't available.
See: http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting
If the initialization stuff could be rewritten to use Railties it would work nicely on Heroku. Will_paginate is a nice example of this.
Cheers!
The text was updated successfully, but these errors were encountered: