0

我正在使用最新版本的 Rails,每次我在本地主机上运行该站点时,它看起来都很好。

但是,终端会打印多个 ActionController::RoutingErrors

在 2013-01-27 23:50:28 -0500 开始获取 127.0.0.1 的“/assets/images/ui-bg_highlight-soft_100_E1EEF4_1x100.png” 服务资产 /images/ui-bg_highlight-soft_100_E1EEF4_1x100.png - 404 未找到( 3毫秒)

ActionController::RoutingError (No route matches [GET] "/assets/images/ui-bg_highlight-soft_100_E1EEF4_1x100.png"): actionpack (3.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:21:in call' actionpack (3.2.11) lib/action_dispatch/middleware/show_exceptions.rb:56:incall' railties ( 3.2.11) lib/rails/rack/logger.rb:32:in call_app' railties (3.2.11) lib/rails/rack/logger.rb:16:inblock in call'activesupport (3.2.11) lib/active_support/tagged_logging.rb:22:in tagged' railties (3.2.11) lib/rails/rack/logger.rb:16:incall' actionpack (3.2.11) lib/action_dispatch/中间件/request_id.rb:22:in call' rack (1.4.4) lib/rack/methodoverride.rb:21:incall' rack (1.4.4) lib/rack/runtime.rb:17:in call' activesupport (3.2.11) lib/active_support/cache/strategy/local_cache.rb:72:incall' rack (1.4.4) lib/rack/lock.rb:15:in call' actionpack (3.2.11) lib/action_dispatch/middleware/static.rb:62:incall' railties (3.2.11) lib/rails/engine.rb:479:in call' railties (3.2.11) lib/rails/application.rb:223:incall' rack (1.4.4) lib/rack/content_length.rb:14:in call' railties (3.2.11) lib/rails/rack/log_tailer.rb:17:incall' rack (1.4.4) lib/rack/handler/webrick .rb:59:inservice' /Users/vicli/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/httpserver.rb:138:in服务'/Users/vicli/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' /Users/vicli/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/server.rb:191:inblock in start_thread'

在救援/布局中渲染 /Users/vicli/.rvm/gems/ruby-1.9.3-p362/gems/actionpack-3.2.11/lib/action_dispatch/middleware/templates/rescues/routing_error.erb (0.9ms)

在 2013-01-27 23:50:28 -0500 开始获取 127.0.0.1 的“/assets/logoo.png” 服务资产 /logoo.png - 304 未修改(0ms)[2013-01-27 23:50: 28] WARN 无法确定响应正文的内容长度。设置响应的内容长度或设置 Response#chunked = true

在 2013-01-27 23:50:28 -0500 开始获取 127.0.0.1 的“/assets/images/ui-bg_glass_65_ffffff_1x400.png” 服务资产 /images/ui-bg_glass_65_ffffff_1x400.png - 404 Not Found (5ms)

ActionController::RoutingError (No route matches [GET] "/assets/images/ui-bg_glass_65_ffffff_1x400.png"): actionpack (3.2.11) lib/action_dispatch/middleware/debug_exceptions.rb:21:in call' actionpack (3.2.11) lib/action_dispatch/middleware/show_exceptions.rb:56:incall' railties (3.2. 11) lib/rails/rack/logger.rb:32:in call_app' railties (3.2.11) lib/rails/rack/logger.rb:16:inblock in call'activesupport (3.2.11) lib/active_support/tagged_logging.rb:22:in tagged' railties (3.2.11) lib/rails/rack/logger.rb:16:incall' actionpack (3.2.11) lib/action_dispatch/middleware/ request_id.rb:22:in call' rack (1.4.4) lib/rack/methodoverride.rb:21:incall' rack (1.4.4) lib/rack/runtime.rb:17:in call' activesupport (3.2.11) lib/active_support/cache/strategy/local_cache.rb:72:incall' rack (1.4.4) lib/rack/lock.rb:15:in call' actionpack (3.2.11) lib/action_dispatch/middleware/static.rb:62:incall' railties (3.2 .11) lib/rails/engine.rb:479:in call' railties (3.2.11) lib/rails/application.rb:223:incall' rack (1.4.4) lib/rack/content_length.rb:14:in call' railties (3.2.11) lib/rails/rack/log_tailer.rb:17:incall' rack (1.4.4) lib/rack/handler/webrick.rb :59:在service' /Users/vicli/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/httpserver.rb:138:in服务'/Users/vicli/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/httpserver.rb:94:in run' /Users/vicli/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/1.9.1/webrick/server.rb:191:inblock in start_thread'

这是我的 routes.db。

  get "planner/index"

  resources :users
  resources :sessions, only: [:new, :create, :destroy]
  root to:'static_pages#home'

  match '/test', to:'planner#update'
  match '/about', to:'static_pages#about'
 match '/home', to:'static_pages#home'
  match '/planner', to:'planner#index'

  resources :sessions, only: [:new, :create, :destroy]

  match '/signup', to: 'users#new'
  match '/signin', to: 'sessions#new'
  match '/signout', to: 'sessions#destroy', via: :delete

  match '/signup', to:'users#new'


  resources :activities


  resources :restaurants

这就是我在运行 rake 路线时得到的

  planner_index GET    /planner/index(.:format)        planner#index
      users GET    /users(.:format)                users#index
            POST   /users(.:format)                users#create
   new_user GET    /users/new(.:format)            users#new
  edit_user GET    /users/:id/edit(.:format)       users#edit
       user GET    /users/:id(.:format)            users#show
            PUT    /users/:id(.:format)            users#update
            DELETE /users/:id(.:format)            users#destroy
   sessions POST   /sessions(.:format)             sessions#create
new_session GET    /sessions/new(.:format)         sessions#new
    session DELETE /sessions/:id(.:format)         sessions#destroy
       root        /                               static_pages#home
       test        /test(.:format)                 planner#update
      about        /about(.:format)                static_pages#about
       home        /home(.:format)                 static_pages#home
    planner        /planner(.:format)              planner#index
            POST   /sessions(.:format)             sessions#create
            GET    /sessions/new(.:format)         sessions#new
            DELETE /sessions/:id(.:format)         sessions#destroy
     signup        /signup(.:format)               users#new
     signin        /signin(.:format)               sessions#new
    signout DELETE /signout(.:format)              sessions#destroy
                   /signup(.:format)               users#new
 activities GET    /activities(.:format)           activities#index
            POST   /activities(.:format)           activities#create
   new_activity GET    /activities/new(.:format)       activities#new
  edit_activity GET    /activities/:id/edit(.:format)  activities#edit
       activity GET    /activities/:id(.:format)       activities#show
            PUT    /activities/:id(.:format)       activities#update
            DELETE /activities/:id(.:format)       activities#destroy
restaurants GET    /restaurants(.:format)          restaurants#index
            POST   /restaurants(.:format)          restaurants#create
 new_restaurant GET    /restaurants/new(.:format)      restaurants#new
edit_restaurant GET    /restaurants/:id/edit(.:format) restaurants#edit
     restaurant GET    /restaurants/:id(.:format)      restaurants#show
            PUT    /restaurants/:id(.:format)      restaurants#update
            DELETE /restaurants/:id(.:format)      restaurants#destroy

我很确定错误是因为我没有正确配置我的路线,但我不知道该怎么做。帮助?

4

2 回答 2

1

这不是路线问题

你只是没有他们必须在的图像(在/assets/images/ui-bg_highlight-soft_100_E1EEF4_1x100.png路径中)

于 2013-01-28T05:13:20.090 回答
0

应用程序期望图像“ui-bg_highlight-soft_100_E1EEF4_1x100.png”和其他图像出现在资产中。图像可能在某些 css 中定义。检查你使用的 css 文件。另外,请查看布局,因为它们也可能在那里使用。在 CSS 中引用图像的正确方法是

background: url(logo25x88.png) no-repeat; #do not set the path if the image is in /assets/images
于 2013-01-28T05:18:23.770 回答