0
我正在使用Devise进行身份验证/注册。我有一个编辑用户页面,该页面设计为我生成的,看起来像这样:设计定制更新控制器
<h2>Edit <%= resource_name.to_s.humanize %></h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email, :autofocus => true %></div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<div><%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, :autocomplete => "off" %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password %></div>
<div><%= f.submit "Update" %></div>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %></p>
<%= link_to "Back", :back %>
的问题是,我的“用户”比色器件为我产生了更多的领域,我想通过那些以及处理由前端用户操作创建的各种场景。基本上,当我点击“更新”提交表单时,我需要定制Devise在后台执行的任何操作。
我该如何重写Devise控制器来实现我所需要的,还是让提交按钮路由到具有我需要的操作的不同更新控制器?
这里是我的路线(经纪人和租房都是一个类型的用户,同义词这些目的):
devise_for:中间商 devise_for:租房
我正在尝试这个为我的更新,但它似乎并没有指向正确的控制器。这是否适用于PUT请求? – user1427661
我有一个小错字,尝试更新我的路线。是的,这应该适用于所有RESTful路由,包括使用PUT方法(即更新)的路由。 – zeantsoi