Hi, I’ve just updated my app to the final 3.1 release and deployed it to the staging server after running tests but there is a problem with the precompiled assets. The precompiled assets are all in the public directory, like they were before, Capistrano doesn’t throw any error and running rake assets:precompile
in the current directory work as expected. But the asset pipeline helpers (javascript_include_tag
and stylesheet_link_tag
) act like if the assets weren’t precompiled. This application have been developed from scratch for 3.1 and deployement worked flawlessly using the release candidates (last used was rc5), I’ve downgraded to our last Gemfile.lock and everything work. So, has something changed since rc5 or is this a bug.
Also, when trying the run rake assets:precompile
on my local machine I get this very strange error message: “Access denied for user ‘root’@‘localhost’ (using password: YES)”. Running rake with --trace
doesn’t give me any more information. I find this error non-sensical, as nothing in this project is owned by the root user. Again downgrading to rc5 make everything work as normal.
the error you are getting running rake assets:precompile locally is that you probably do npt have the production database setup locally and for some reason it tries to connect to the production database, I fixed this error by simply creating the production database locally.
I can’t help with the other problem as I am still trying to figure out how to deploy these assets, they really seem more trouble than they are worth 
the error you are getting running rake assets:precompile locally is that you probably do npt have the production database setup locally and for some reason it tries to connect to the production database, I fixed this error by simply creating the production database locally.
Well, that seems to make some sense, though I don’t see why the assets precompilation would hit the database. This is working flawlessly using rc5, so something must have changed in Rails.
I can’t help with the other problem as I am still trying to figure out how to deploy these assets, they really seem more trouble than they are worth 
Should be relatively easy if you’re starting with 3.1, I just added this:
after('deploy:symlink', 'assets:precompile')
namespace :assets do
desc ‘Precompile assets’
task :precompile, :roles => :app do
run “cd #{current_path}; RAILS_ENV=#{stage} rake assets:precompile”
end
end
to the deploy.rb file, pretty standard Capistrano stuff. Never had any problem with the RCs!
But for existing project, it’s another story. One coworker tried to convert a big project and gave up after a while as this project already used many complex scss files with lots of @include statements.
I’m eagerly awaiting 3.1.1! 
I could deploy that way although the latest capistrano does seem to have a builtin for assets if you load ‘deploy/assets’, however I want to precompile locally and upload the resulting public/assets. I don’t want to have to deploy all the assets stuff to my production server and precompile on the server, it makes more sense to me to precompile locally.
So I’ll have to write a bunch of custom stuff for capistrano to do that.
There is a discussion thread on the capistrano ML about this.
I’ve finally fixed the problem I had, it was a relatively subtle point that I found in the guide. For a staging environment you have to set this config variable:
config.assets.digest = true
for the helpers to use fingerprinting. This is because Rails only set this to true for the production environment by default. This behavior was different in RC5 and previous release.
Also, I updated bundler to the latest version, replaced the custom deploy task by adding load 'deploy/assets'
to my Capfile and made sure to make a symlink to the shared database.yml file before the deploy:assets:precompile
capistrano task.