【发布时间】:2016-05-31 01:42:29
【问题描述】:
我为设计构建了 2 个自定义视图,1 个更改密码,另一个更新其他自定义信息。密码更新成功了,所以我复制了第二个视图的方法,但是在提交数据时出现错误
No route matches [PATCH] "/users/discovery_settings/update"
这没有意义,因为我的路线是
devise_for :users, controllers: {registrations: 'users/registrations'}
as :user do
end
get 'users/discovery_settings' => 'users#discovery_settings'
post 'users/discovery_settings/update' => 'users#update_discovery'
在我的控制器中,我使用与密码更新相同的方法
def update_discovery
@user = User.find(current_user.id)
if @user.update(user_params)
# Sign in the user by passing validation in case their password changed
sign_in @user, :bypass => true
redirect_to root_path
else
render "edit"
end
end
然后我在我的 form_for 视图中调用它
<%= form_for(@user, :url => { :action => "update_discovery" }, html: {class: "form floating-label"}) do |f| %>
任何想法如何解决路由错误? 当我已经指定“帖子”时,我不知道为什么它正在寻找“补丁”
【问题讨论】:
-
我的忍者设计大师在哪里?
标签: ruby-on-rails devise routes