I have a defined User and I want to be able to let him confirm his account be reentering his email and names (because those have been filled by a third party). So here is what I have:
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
And in my template I have:
<%= 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 %>
However, when I click on the Submit button, I see in the logs the following:
(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)
Why is not letting me try to update the user?
Thanks
Because you aren’t defining it.
See how the other actions in the Devise::RegistrationsController define
resourcehere:https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb