0

我有一个已定义的用户,我希望能够让他确认他的帐户正在重新输入他的电子邮件和姓名(因为这些已由第三方填写)。所以这就是我所拥有的:

def confirm_account
    if request.get?
      self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
    elsif request.put?
      self.resource = build_resource(resource_params)
      if self.resource.save 
      else
        respond_with resource
      end
    end
  end

在我的模板中,我有:

<%= simple_form_for(resource, :as => resource_name, :url => confirm_account_path(resource_name), :html => { :method => :put, :autocomplete => "off", :class => 'form-vertical' }) do |f| %>
  <%= devise_error_messages! %>
    <h1> Create your Account </h1>
    <%= f.input :first_name, :label => "First Name" %>
    <%= f.input :last_name, :label => "Last Name" %>
    <%= f.input :email, :label => "Email add." %>
  <p>
    <%= f.button :submit, "Create account" %>
  </p>
<% end %>

但是,当我单击提交按钮时,我在日志中看到以下内容:

   (0.3ms)  BEGIN
  User Exists (0.5ms)  SELECT 1 AS one FROM "users" WHERE "users"."email" = 'myemail@gmail.com' LIMIT 1
   (0.3ms)  ROLLBACK
Completed 406 Not Acceptable in 5ms (ActiveRecord: 1.1ms)

为什么不让我尝试更新用户?

谢谢

4

1 回答 1

1

因为你没有定义它。

在此处查看Devise::RegistrationsController 中的其他操作如何定义resourcehttps ://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb

于 2013-01-19T11:58:21.043 回答