首先,检查你的路线去安慰,做
rake routes | grep session
那里你会得到清单Rails应用程序的所有路由(匹配到grep的)
在第二我不明白你的routes.rb
会怎么做
resources :session, :only => [update] do
match '/:controller(/:action(/:id))'
end
或
resources :session, :only => [update]
match '/:controller(/:action(/:id))'
end
这些都是2个不同的东西。我想你想要最后一个。但在这里我们去,还有另一个问题
resources :session, :only=>[update]
,这将引发一个错误。(未定义的局部变量或方法'更新”的#) 如果要指定动作,你需要做它作为一个重点
resources :session, :only=>[:update]
但你也想编辑消息,(编辑的形式,更新的动作保存更改),所以你要做的
resources :users, :only=>[:edit, :update]
现在检查耙路线,看看voil一个!
edit_session GET /session/:id/edit(.:format) {:action=>"edit", :controller=>"session"}
session PUT /session/:id(.:format) {:action=>"update", :controller=>"session"}
//编辑
,如果你想这样做在你的admin_controller你应该有一个命名空间
#i take example for a user
namespace :admin do
resources :user :only => [:edit, :update]
end
,如果你现在想从视图的路线链接到它被命名为 edit_admin_user_path
并且您需要在窗体中带上名称空间_for like:
=form_for [:admin, @user] do |f|