**更新:这个问题是关于Rails中的一个错误:**
https://rails.lighthouseapp.com/projects/8994/tickets/267
**结束更新。 **
我尝试使用单一资源(根据here)因为我喜欢更好的类型网址
/user/new
与
相比/users/new
所以在我的routes.rb中我改变了
resources :users
到
resources :user, :controller => 'users'
现在在我看来命令
form_for(@user) do |f|
给出错误:
No route matches {:controller=>"users"}
有任何线索吗?
这是佣金路线的输出
user_index GET /user(.:format) {:action=>"index", :controller=>"users"}
POST /user(.:format) {:action=>"create", :controller=>"users"}
new_user GET /user/new(.:format) {:action=>"new", :controller=>"users"}
edit_user GET /user/:id/edit(.:format) {:action=>"edit", :controller=>"users"}
user GET /user/:id(.:format) {:action=>"show", :controller=>"users"}
PUT /user/:id(.:format) {:action=>"update", :controller=>"users"}
DELETE /user/:id(.:format) {:action=>"destroy",:controller=>"users"}
答案 0 :(得分:3)
请尝试resource :user
而不是resources :user
,因为这是一条单一的路线
一条独特的资源丰富的路线会产生这些帮助:
因此,users_path
现在为user_path
。
答案 1 :(得分:2)
这个问题是关于Rails中的一个错误: