2

我的 Rails 应用程序在处于开发模式时工作得很好,但是如果我将其更改为生产模式,它会给出一些错误错误,我看不出它背后的任何原因。你知道任何可能的问题吗?

这是我的错误信息:

Started GET "/favicon.ico" for 127.0.0.1 at Mon Apr 30 00:55:16 +0300 2012

ActionController::RoutingError (No route matches [GET] "/favicon.ico"):
  actionpack (3.2.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  railties (3.2.1) lib/rails/rack/logger.rb:26:in `call_app'
  railties (3.2.1) lib/rails/rack/logger.rb:16:in `call'
  actionpack (3.2.1) lib/action_dispatch/middleware/request_id.rb:22:in `call'
  rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
  rack (1.4.1) lib/rack/runtime.rb:17:in `call'
  activesupport (3.2.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  rack (1.4.1) lib/rack/lock.rb:15:in `call'
  rack-cache (1.1) lib/rack/cache/context.rb:132:in `forward'
  rack-cache (1.1) lib/rack/cache/context.rb:241:in `fetch'
  rack-cache (1.1) lib/rack/cache/context.rb:181:in `lookup'
  rack-cache (1.1) lib/rack/cache/context.rb:65:in `call!'
  rack-cache (1.1) lib/rack/cache/context.rb:50:in `call'
  railties (3.2.1) lib/rails/engine.rb:479:in `call'
  railties (3.2.1) lib/rails/application.rb:220:in `call'
  rack (1.4.1) lib/rack/content_length.rb:14:in `call'
  railties (3.2.1) lib/rails/rack/log_tailer.rb:14:in `call'
  rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
  /home/erogol/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  /home/erogol/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  /home/erogol/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
  /home/erogol/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/webrick/server.rb:162:in `start'
  /home/erogol/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
  /home/erogol/.rvm/rubies/ruby-1.8.7-p358/lib/ruby/1.8/webrick/server.rb:95:in `start'
  /home/erogol/.rvm/ru

谢谢大家关心...

当我输入 rake assets:precompile 我得到:

rake aborted!
no such file to load -- uglifier
  (in /home/erogol/Dropbox/Bunch_It/app/assets/javascripts/application.js)

Tasks: TOP => assets:precompile:primary
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [/home/erogol/.rvm/rubies/ruby-1.8.7-p358/b...]

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
4

4 回答 4

2

尝试config.serve_static_assets = true\config\environments\production.rb文件中设置。这对我有帮助。

于 2012-09-10T05:42:19.447 回答
1

从报错信息来看,Rails 找不到文件:/favicon.ico。请确保它存在。

于 2012-04-29T22:32:30.407 回答
1

如果这只是在生产中而不是在开发中,我的第一个猜测是你可能需要编译你的资产。您需要运行:

rake assets:precompile

或更改您的production.rb环境文件以包括:

config.assets.compile = true

但是,错误消息中的路径/favicon.ico不是assets/favicon.ico. 而且,favicon 文件应该只是在您的/public目录中。你能确认这是文件所在的位置吗?

于 2012-04-29T22:43:28.883 回答
0

问题是关于config.assets.compress = true. 它对我的 javascript 文件造成了问题。我将其设置为 false,我的应用程序开始正常工作。但是我不知道将其设为假是否会导致我的程序丢失。

于 2012-04-29T23:19:29.993 回答