0
I was implementing the Gem Devise in the Rubyonrails and everything was working perfectly.
Then I went to add the "confirmable" module. I took the following steps:
I added :confirmable
in Usuarios.rb
:
class Usuario < ActiveRecord::Base
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
# adicionado por mim
:confirmable
end
I created the Migration file:
class AddConfirmableToUsuarios < ActiveRecord::Migration
def change
change_table(:usuarios) do |t|
t.string :confirmation_token
t.datetime :confirmed_at
t.datetime :confirmation_sent_at
t.string :unconfirmed_email
end
end
end
In the views I had to fix some urls by adding usuario
in helpers, for example:
new_confirmation_path(resource_name)
# para
new_usuario_confirmation_path(resource_name)
However, when sending the form to views/devise/confirmation/new.html.erb
i get 406 code "not accptable" and error ActionController::UnknownFormat in Devise::ConfirmationsController#create
. Despite this the confirmation email is sent and the link sent is validated and the account can be validated.
Follow the form below:
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, as: resource_name, url: usuario_confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %></div>
<div><%= f.submit "Resend confirmation instructions" %></div>
<% end %>
That’s right, it worked. Thanks :)
– user7261