Pau*_*rit 3 ruby haml ruby-on-rails
Rails 3.0.9 withhaml gem & Ruby 1.9.2-head with rvm
我有订单资源。
route.rb 文件的片段
resources :orders
Run Code Online (Sandbox Code Playgroud)
使用 Order 模型实例调用 link_to 助手返回 /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
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
我还有其他资源,但它们工作正常。
更新:
我的 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
Run Code Online (Sandbox Code Playgroud)
我认为你应该删除
match '/order', :to => ...
Run Code Online (Sandbox Code Playgroud)
从你的路线文件。
| 归档时间: |
|
| 查看次数: |
3541 次 |
| 最近记录: |