We're having a small issue with our app. Currently we've made an update of the internal design and uploaded to the server, however running the following;
RAILS_ENV=production bundle exec rake assets:precompile
only precompiles certain items into the asset folder under public directory. Anyone else ran into the problem like this with suggestion how to fix. We have everything set correctly in environments and initializers.
Sounds like some files are not getting into the precompile list. Try adding this to your config/application.rb
config.assets.precompile = [/^[^_]/]
This should be a catch all that will pick up all your js and css. Let me know if that works for you guys. Also you should be sure to tell that guy that you are listening to that deploying via FTP is silly.
Related
While creating a Rails application:
user$ rails new App
All the other files get created, i.e. app, config, db, doc, script, test, Gemfile, etc I find that the Gemfile.lock fails to be created. Any particular reason why this could be happening? I am facing errors in bundling gems, though I do not know whether the absence of the Gemfile.lock file is causing this. Please help!
you dont get a lock until after you do your bundle, and whenever there is a well form group of gems built (with all dependancies available..)
if you run:
bundle install
I think one should get created for you.
or
bundle update
if you have a lock file and have an updated gemset
I'm in the process of upgrading a 3.0 Rails App to 3.1.4 including the Asset Pipeline.
I'm on Heroku, so I'm I have this in my application.rb
config.assets.initialize_on_precompile = false
I noticed that when I run:
bundle exec rake assets:precompile
it creates files in a public/assets directory (even though my assets are in app/assets already).
For example, it creates files like application-72b2779565ba79101724d7356ce7d2ee, as well as replicating the images I have in app/assets.
My questions are:
(1) should be uploading these files to my production server?
(2) if I'm suppose to be uploading these, am I suppose to update each application-xxxxxxxx or only the latest one?
To your first question: Heroku will not allow you to modify the filesystem. So your assertion is correct- You will need to pre-compile the asset pipeline before you send it up to Heroku, so that it can be utilized in your production environment.
And the latter: You'll want to make sure you have the latest compilation. Any others wont be used. The "xxxxxxx" portion is to make sure that your users have the latest and greatest version of your assets. It's a way of versioning what the browser gets, and making sure they're not caching a bad copy of the JavaScript, when you want to set up their cache to hold on to the JS and CSS files as long as they can, instead of constantly getting it from your web server.
Take my Heroku comments with a slight grain of salt, as I have not deployed to Heroku before. I just know how their system works to some degree.
Currently it seems Heroku is determined to pre-compile assets when I push my code up to my instances.
This is great for production servers, however for my "RAILS_ENV=development" server, this causes issues, as I now get pages with all the JavaScript files served up individually from my asset manifest, and then another file with the same code all grouped up as the pre-compiled asset.
This cause my jquery datatables libraries to break, throwing popup errors, which I don't get on my local environment (development or production) or in my production Heroku instance.
Is there anyway to disable pre-compilation of assets on Heroku for development mode instances ? Or is there any reason why these aren't already disabled on development Heroku servers already ?
If Heroku detect a public/assets/manifest.yml file then they will not attempt to precompile your assets and assume you are dealing with them yourself. More details at http://devcenter.heroku.com/articles/rails31_heroku_cedar
AFAIK, Heroku has to precompile assets to work around their readonly FS and the fact that the Rails asset pipeline wants to write files to the FS. The only thing I could suggest would be to work out why your assets are breaking when being compiled.
I worked around this by adding some voodoo to my Rakefile to disable the assets:precompile rake task.
first I add the user-env-compile labs component
heroku labs:enable user-env-compile
then add this to the beginning of my Rakefile
# found from http://blog.jayfields.com/2008/02/rake-task-overwriting.html
# used by conditional heroku asset compile magick
class Rake::Task
def overwrite(&block)
#actions.clear
enhance(&block)
end
end
Then I add this rake task in lib/tasks/disable_assets_on_heroku.rake
if ENV['RAILS_ENV'] == 'development'
namespace :assets do
task(:precompile).overwrite do
puts "Asset precompile skipped in #{ENV['RAILS_ENV']}"
end
end
end
Since I'm running my app on the Bamboo stack I'm precompiling my assets and committing them.
I've included the file manifest.yml in public/assets/ but heroku doesn't detect it. As a result it tries to compile assets and borks itself.
Am I missing something?
Ok, I discovered that I was trying to serve up unprocessed files from the public directory.
Also, I migrated my app to cedar which helped too. :)
I tried rake gem:unpack but I get task not found. I would like to have refinery gems in my /vendor directory to be able to see the never ending views and partials and may be modify them.
I'm still learning how to do things the "Rails way", but I feel your need to have the files in a directory that's easy to see. One command I found that will dump in vendor in the local project is bundle install --deployment. You'll need to run this after initially doing a bundle install.
run bundle package
more here: http://gembundler.com/bundle_package.html