我正在尝试使用复选框在设置页面中更新我的个人资料设置。一旦复选框被点击,我想重定向到设置页面,所以我添加了一个新的动作到我的控制器更新配置文件,但重定向到设置。不过,我发现了以下错误:Form_for错误 - 无路线匹配帖子
`No route matches {:action=>"edit_settings", :controller=>"profiles"}`
这里是我的form_for
代码:
<%= form_tag({:action => "edit_settings", :controller => "profiles"}, :html => {:multipart => true }) do |f| %>
我edit_settings
行动,我profiles
控制器:
def edit_settings
@profile = user.profile
if @profile.update_attributes(params[:profile])
redirect_to settings_path, :notice => 'Updated user information successfully.'
else
render :edit
end
end
里面我routes.rb
文件:
resources :profiles do
post :edit_settings
end
内rake routes
:
profile_edit_settings POST /profiles/:profile_id/edit_settings(.:format) {:action=>"edit_settings", :controller=>"profiles"}
很好的解释,谢谢!添加'匹配“配置文件/ edit_settings”,:到=>“profiles#edit_settings'到我的路线文件工作。 – tvalent2 2012-01-12 02:12:33