我已将rails的应用程序升级到rails版本3。 当我在开发模式下启动应用程序时,所有工作。 但是当我在生产模式下启动时,所有本地图像都没有显示
例如:
http://localhost:3000/images/background.jpg
我收到此错误:
Started GET "/images/background.jpg?1254155492" for 127.0.0.1 at Fri Nov 26 16:42:53 +0100 2010
ActionController::RoutingError (No route matches "/images/background.jpg"):
actionpack (3.0.3) lib/action_dispatch/middleware/show_exceptions.rb:53:in `call'
railties (3.0.3) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `synchronize'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
railties (3.0.3) lib/rails/application.rb:168:in `call'
railties (3.0.3) lib/rails/application.rb:77:in `send'
railties (3.0.3) lib/rails/application.rb:77:in `method_missing'
railties (3.0.3) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.1) lib/rack/content_length.rb:13:in `call'
rack (1.2.1) lib/rack/handler/webrick.rb:52:in `service'
/accounts/lromagnoli/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/accounts/lromagnoli/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/accounts/lromagnoli/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/accounts/lromagnoli/lib/ruby/1.8/webrick/server.rb:162:in `start'
/accounts/lromagnoli/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/accounts/lromagnoli/lib/ruby/1.8/webrick/server.rb:95:in `start'
/accounts/lromagnoli/lib/ruby/1.8/webrick/server.rb:92:in `each'
/accounts/lromagnoli/lib/ruby/1.8/webrick/server.rb:92:in `start'
/accounts/lromagnoli/lib/ruby/1.8/webrick/server.rb:23:in `start'
/accounts/lromagnoli/lib/ruby/1.8/webrick/server.rb:82:in `start'
rack (1.2.1) lib/rack/handler/webrick.rb:13:in `run'
rack (1.2.1) lib/rack/server.rb:213:in `start'
railties (3.0.3) lib/rails/commands/server.rb:65:in `start'
railties (3.0.3) lib/rails/commands.rb:30
railties (3.0.3) lib/rails/commands.rb:27:in `tap'
railties (3.0.3) lib/rails/commands.rb:27
script/rails:6:in `require'
script/rails:6
Rendered /accounts/lromagnoli/lib/ruby/gems/1.8/gems/actionpack-3.0.3/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.9ms)
为什么?
我该如何解决?
感谢
答案 0 :(得分:4)
您需要更改config/environments/production.rb
中的配置
config.serve_static_assets = false
到
config.serve_static_assets = true
答案 1 :(得分:0)
您也可以尝试这样做:
config.assets.compile = true