没有路线匹配新的节目路线

时间:2012-01-26 13:29:16

标签: ruby-on-rails ruby ruby-on-rails-3

ActionController::RoutingError

No route matches {:controller=>"user_prices", :action=>"show".....

这是我在视图中更改路线时遇到的错误:

<td class="show-link"><%= link_to "Show", show_price_path(user_price) %></td>

来自我的新路线:

match "/:id/:product_name/:purchase_date/:price", :to => "user_prices#show", :as => :show_price

我该怎么做才能使用此路线查看我的用户价格?

1 个答案:

答案 0 :(得分:4)

您指定的路线

/:id/:product_name/:purchase_date/:price

需要4个参数才能创建。你只传递一个对象,我认为这是为了id。使用您指定的路线,您需要执行类似的操作。

show_price_path(:id=>user_price.id, :product_name=>product_name_from_user_price, :purchase_date=>purchase_date_from_user_price, :price=>price_from_user_price)