ruby on rails - Can Devise allow multiple emails for password recovery? -
i have following situation: person model includes userable:
class person < activerecord::base include userable end
this userable has many emails:
module userable extend activesupport::concern included has_one :user, as: :userable has_many :emails, as: :emailable, dependent: :destroy end end
email has model too:
class email < activerecord::base belongs_to :emailable, polymorphic: true validates :address, presence: true, format: { with: /\a[a-za-z0-9._%+-]+@([a-za-z0-9.-]+\.)+[a-za-z]+\z/} end
and finally, user model:
class user < activerecord::base # devise properties devise :database_authenticatable, :rememberable, :trackable, :timeoutable, :recoverable end
i'm trying create "forgot password" thing recover user password sending email user. problem 'email' not method @ user. so, when load path "users/password/new" gives me error:
undefined method `email' #user:0x0...
so, there way can change form send email person email?
<h2>forgot password?</h2> <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post }) |f| %> <%= devise_error_messages! %> <div><%= f.label :email %><br /> <%= f.email_field :email, :autofocus => true %></div> <div><%= f.submit "send me reset password instructions" %></div> <% end %> <%= render "devise/shared/links" %>
Comments
Post a Comment