我正在为我的用户帐户使用设备,在那里我将获得所有的确认,用户密码指令等;但是我有一个条件,如果用户帐户被锁定(在我的场景中状态是假的),他必须通过电子邮件获得一个重置密码链接。这个锁定过程是在其他控制器中编码的,因此我们不能使用devise。
我的控制器代码:
def send_instruction a=[] 如果@ << '1‘结束如果@应答2 << '2’结束如果@ << '3‘结束如果a.size <= 1 SiteMailer.unlock_user(current_user).deliver current_user.update_attribute(:status,false) destroy_user_session_path(current_user) flash:error=“您的帐户被锁定”redirect_to new_user_session_path redirect_to user_dashboard_path end
mailers/site_mailer.rb:
类SiteMailer < ActionMailer::Base 包括设计::邮递员::助手 默认来源:"support@example.com“def unlock_user(用户) @user = user @url = "pwd_edit“邮件(致:@user.email,主题:‘您的帐户已被锁定’) 结束 结束
在mailer视图中:
嗨, 你的账户被锁上了。编辑简介:“我的链接(edit_user_password_url(current_user)”)。
当我通过这个过程,我得到了“没有找到路线”错误。我的路线是正确的。请帮帮我。
发布于 2013-12-22 06:56:45
那是因为当时没有current_user。你应该试试这个
edit_user_password_url(@user) https://stackoverflow.com/questions/20726934
复制相似问题