Rails ActionView :: TemplateError(shop_url无法生成

时间:2010-11-24 18:06:03

标签: ruby-on-rails

我收到了这个,但我没有更改任何这些代码。我的开发环境非常好。这种情况发生在生产中。

当存在匹配的条目时会发生这种情况。如果没有匹配的条目,那就没关系(显然!)。

Processing ShopsController#index (for 118.100.246.177 at 2010-11-25 01:46:48) [GET]
  Parameters: {"country"=>"France", "action"=>"index", "filter"=>"on", "order"=>"rating_descend", "type"=>"places", "controller"=>"shops", "keyword"=>""}
Rendering template within layouts/application
Rendering shops/index

ActionView::TemplateError (shop_url failed to generate from {:type=>"places", :action=>"show", :controller=>"shops"}, expected: {:controller=>"shops", :action=>"show"}, diff: {:type=>"places"}) on line #50 of app/views/shops/index.html.erb:
47: 
48:               <% @shops.each do |shop| %>
49:                 <div id="<%= dom_id(shop) %>" class="item">
50:                   <a href="<%= shop_path(shop, :type => @type) %>">
51:                     <% if !shop.photos.blank? %>
52:                       <%= image_tag(shop.photos.last.url(:thumb), :class => 'thumbnail') %>
53:                     <% else %>

    facebooker (1.0.75) lib/facebooker/rails/facebook_url_rewriting.rb:53:in `rewrite_url'
    facebooker (1.0.75) lib/facebooker.rb:200:in `request_for_canvas'
    facebooker (1.0.75) lib/facebooker/rails/facebook_url_rewriting.rb:52:in `rewrite_url'
    (eval):17:in `shop_path'
    app/views/shops/index.html.erb:50
    /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.20/lib/thinking_sphinx/search.rb:137:in `each'
    /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.20/lib/thinking_sphinx/search.rb:137:in `send'
    /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/thinking-sphinx-1.3.20/lib/thinking_sphinx/search.rb:137:in `method_missing'
    app/views/shops/index.html.erb:48
    /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/authlogic-oauth-1.0.8/lib/oauth_callback_filter.rb:10:in `call'
    /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/authlogic-oauth-1.0.8/lib/oauth_callback_filter.rb:10:in `call'
    passenger (2.2.15) lib/phusion_passenger/rack/request_handler.rb:92:in `process_request'
    passenger (2.2.15) lib/phusion_passenger/abstract_request_handler.rb:207:in `main_loop'
    passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:441:in `start_request_handler'
    passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:381:in `handle_spawn_application'
    passenger (2.2.15) lib/phusion_passenger/utils.rb:252:in `safe_fork'
    passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:377:in `handle_spawn_application'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:163:in `start'
    passenger (2.2.15) lib/phusion_passenger/railz/application_spawner.rb:222:in `start'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:253:in `spawn_rails_application'
    passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:126:in `lookup_or_add'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:247:in `spawn_rails_application'
    passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:80:in `synchronize'
    passenger (2.2.15) lib/phusion_passenger/abstract_server_collection.rb:79:in `synchronize'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:246:in `spawn_rails_application'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:145:in `spawn_application'
    passenger (2.2.15) lib/phusion_passenger/spawn_manager.rb:278:in `handle_spawn_application'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `__send__'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:352:in `main_loop'
    passenger (2.2.15) lib/phusion_passenger/abstract_server.rb:196:in `start_synchronously'

Rendering template within layouts/application
Rendering errors/500.html.erb (500)
[paperclip] Saving attachments.

当我的typegaragesmalls等其他人时,他们都运作良好。我甚至重建了我的思维斯芬克斯指数。

更新 从1,2,3得出MySQL ID自动增量...我删除了1,2,3条,并用200000,200001,200002替换了ID,这给了我一些问题。不知道Rails是如此严格。

1 个答案:

答案 0 :(得分:1)

从错误消息中可以清楚地看到。 :type =&gt; "places"让你感到悲伤。您可能需要将"?type=places固定到生成的URL的末尾,如果这是您真正要传递给控制器​​的内容。