【发布时间】:2014-04-06 07:35:33
【问题描述】:
在生产中,我在日志中得到以下信息:
我,[2013-11-28T10:37:59.495396 #1181] 信息 -- : 开始获取 91.104.133.126 的“/javascripts/application.js”于 2013 年 11 月 28 日 10:37:59 +0000 F,[2013-11-28T10:37:59.497931 #1181] 致命——: ActionController::RoutingError (没有路由匹配 [GET] “/javascripts/application.js”):
还有:
我,[2013-11-28T10:41:05.611348 #1181] INFO -- : Started GET "/" for 91.104.133.126 at 2013-11-28 10:41:05 +0000 I, [2013-11-28T10:41:05.615742 #1181] INFO -- : 处理 PagesController#home 作为 HTML I,[2013-11-28T10:41:05.626276 #1181] INFO -- : 在 layouts/application 中渲染 pages/home.html.erb (7.5 毫秒)我,[2013-11-28T10:41:05.629343 #1181] 信息 -- :已完成 200 13 毫秒内确定(查看:10.5 毫秒 | ActiveRecord:0.8 毫秒)我, [2013-11-28T10:41:05.817024 #1181] 信息 -- : 开始获取 2013 年 11 月 28 日 91.104.133.126 的“/stylesheets/application.css” 10:41:05 +0000 F,[2013-11-28T10:41:05.819748 #1181] 致命——: ActionController::RoutingError (没有路由匹配 [GET] "/stylesheets/application.css"):
这在开发过程中没有发生。
应用与 RVM & NginX & Passenger 一起运行,所有最新版本,全新安装。
更新 1:
运行RAILS_ENV=production bundle exec rake assets:precompile 后,我得到了这些:
ActionController::RoutingError(没有路由匹配 [GET] "/assets/application-0292b59e3ea25ff21b6f72e062924c42.css"):
actionpack (4.0.1) lib/action_dispatch/ActionController::RoutingError(没有路由匹配 [GET] “/javascripts/vendor/modernizr.js”):
ActionController::RoutingError(没有路由匹配 [GET] “/assets/application-2f1ac76c2ad0b69f7bbab4b9d9dca4b8.js”):
更新 2:
rake routes的输出
Prefix Verb URI Pattern Controller#Action
images_new GET /images/new(.:format) images#new
users_sign_up GET /users/sign_up(.:format) users#sign_up
images_edit GET /images/edit(.:format) images#edit
images_index GET /images/index(.:format) images#index
images_show GET /images/show(.:format) images#show
posts_new GET /posts/new(.:format) posts#new
posts_edit GET /posts/edit(.:format) posts#edit
posts_update GET /posts/update(.:format) posts#update
posts_destroy GET /posts/destroy(.:format) posts#destroy
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create new_user_registration GET
/users/sign_up(.:format) devise/registrations#new edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PATCH /users(.:format) devise/registrations#update
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
pages_home GET /pages/home(.:format) pages#home
posts GET /posts(.:format) posts#index
POST /posts(.:format) posts#create
new_post GET /posts/new(.:format) posts#new
edit_post GET /posts/:id/edit(.:format) posts#edit
post GET /posts/:id(.:format) posts#show
PATCH /posts/:id(.:format) posts#update
PUT /posts/:id(.:format) posts#update
DELETE /posts/:id(.:format) posts#destroy
images GET /images(.:format) images#index
POST /images(.:format) images#create
new_image GET /images/new(.:format) images#new
edit_image GET /images/:id/edit(.:format) images#edit
image GET /images/:id(.:format) images#show
PATCH /images/:id(.:format) images#update
PUT /images/:id(.:format) images#update
DELETE /images/:id(.:format) images#destroy
root GET / pages#home
【问题讨论】:
-
你跑
rake assets:precompile了吗? -
当我尝试运行它时,我得到这个:rake aborted!数据库配置未指定适配器
-
好的,那
RAILS_ENV=production bundle exec rake assets:precompile呢? -
这个没有错误,但仍然得到相同的日志消息。
-
您是否在视图中使用了asset_url('path_to_asset')?
标签: ruby-on-rails nginx routes passenger