광산 사이트에서 이와 동일한 흐름을 만들었습니다.
scope :path => '/users', :controller => 'users' do
match 'verify_email' => :verify_email, :as => 'verify_email'
match 'edit_account_email' => :edit_account_email, :as => 'edit_account_email'
match 'update_account_email' => :update_account_email, :as => 'update_account_email'
end
에 추가 가 (라우팅이 더있을 수 있습니다,하지만 난 얼마 전에 이런 짓을)/
추가가 config (설정) 할 routes.rb : 여기에 당신이 할 수있는 일의 예 응용 프로그램/컨트롤러/users_controller.rb
def edit_account_email
@user=current_user
end
def update_account_email
@user=current_user
@user.password_not_needed=true
@user.email=params[:address]
if @user.save
flash[:notice]="your login email has been successfully updated."
else
flash[:alert]="oops! we were unable to activate your new login email. #{@user.errors}"
end
redirect_to edit_user_path
end
def verify_email
@user=current_user
@address=params[:address]
UserMailer.confirm_account_email(@user, @address).deliver
end
응용 프로그램/우편물/user_mailer.rb
class UserMailer < ActionMailer::Base
def confirm_account_email(user, address)
@user = user
@address = address
mail(
:to=>"#{user.name} <#{@address}>",
:from=>"your name <'[email protected]'>",
:subject=>"account email confirmation for #{user.name}"
)
end
end
응용 프로그램/뷰/user_mailer/confirm_account_email.html.erb
<p>you can confirm that you'd like to use this email address to log in to your account by clicking the link below:</p>
<p><%= link_to('update your email', update_account_email_url(@user, :address=>@address)) %></p>
<p>if you choose not to confirm the new address, your current login email will remain active.
이 어떤 도움이됩니까? https://github.com/Mandaryn/devise/commit/92ee45e60d65b5e127f74973ea866ed7d4dcef20 – MKK
다음 단계를 모두 수행하면 전자 메일을 변경할 수있는 "프로필 편집 (전자 메일)"페이지를 어떻게 준비 할 수 있습니까? https://github.com/heimidal/devise/commit/1961de6b5deb7c1799a265d506221fef9d7bb6a9 – MKK