Rails 3.0.9 with haml gem& Ruby 1.9.2-head with rvm
我有订单资源。
routes.rb文件的片段
resources :orders
使用Order模型的实例调用link_to helper返回/order.2而不是/ orders / 2.
order_controller.rb和index.html.haml的片段
#index.haml.html
%ul
- @orders.each do |item|
%li= link_to item.id, item #=> <a href="/order.2">2</a> instead of <a href="/orders/2">2</a>
#orders_controller.rb
def index
@orders = Order.all
end
我做错了什么?
我还有其他资源但工作正常。
更新
我的routes.rb文件列表
YetApp::Application.routes.draw do
resources :categories, :products, :images, :orders, :small_images
match "/order", :to => "orders#new", :as=> 'order'
match "/success/:id", :to => "orders#success", :as=> 'order'
#namespace :signed do
# resources :products, :images, :categories
#end
root :to => 'pages#home'
match '/signed', :to => 'pages#signed', :as => 'signed'
match '/cooperation', :to => 'pages#cooperation', :as => 'cooperation'
match '/payment', :to => 'pages#payment', :as => 'payment'
match '/offer', :to => 'pages#offer', :as => 'offer'
match '/order', :to => 'pages#order', :as => 'order'
end
答案 0 :(得分:4)
我认为你应该删除
match '/order', :to => ...
来自路线档案。