Asset Pipeline: Trouble on deploying my Rails 3.1

2019-04-15 03:12发布

问题:

I am using Ruby on Rails 3.1.0 and Capistrano. I have a problem on make the application to work in production mode (the remote machine is running Ubuntu 10.4 - my local machine is a MacOS running Snow Leopard 10.6.7).

When I deploy with Capistrano I get this error:

uninitialized constant Rake::DSL

When I try to access a web page I get this error:

ActionView::Template::Error (application.css isn't precompiled)

What I should to do in order to make the application to work in production mode on the remote machine?


In my Capfile file I have:

# Uncomment if you are using Rails' asset pipeline
load 'deploy/assets'

In my Gemfile file I have:

group :production do
  gem 'execjs'
  gem 'therubyracer'
end

If I comment the load 'deploy/assets' I do not get anymore the uninitialized constant Rake::DSL but I get still the ActionView::Template::Error (application.css isn't precompiled) error.

回答1:

See:

http://guides.rubyonrails.org/asset_pipeline.html#precompiling-assets

"
If you have other manifests or individual stylesheets and JavaScript 
files to include, you can add them to the precompile array:

config.assets.precompile += ['admin.js', 'admin.css', 'swfObject.js']
"


回答2:

Try to add config.assets.compile = true in production.rb. Hope that helps.



回答3:

Try to create new Rails 3.1 project with scaffolding and deploy it. If everything will be ok, compare configs and other files with your real project.