2016-03-08 60 views
0

用户在我的站点注册后,他们需要激活他们的帐户。电子邮件将发送给用户。如果帐户未激活,用户将无法登录。如何在controller.rb中添加按钮链接 - rails 4

一条消息将显示,说:“帐号未激活查看您的邮箱激活链接。”如何在提示服务器向用户发送另一封激活邮件的警告消息中创建链接或按钮?

我试过action_item<%=button_to

def create 
    user = User.find_by(email: params[:session][:email].downcase) 
    if user && user.authenticate(params[:session][:password]) 
    if user.activated? 
     log_in user 
     params[:session][:remember_me] == '1' ? remember(user) : forget(user) 
     redirect_back_or user 
    else 
     message = "Account not activated. " 
     message += "Check your email for the activation link. " 
     flash[:warning] = message 
     action_item :view, only: :show do 
     link_to 'Resend the activation link.', :action => "@user.send_password_reset_email", :controller => "PasswordResets" 
    end 
    redirect_to root_url 
    end 
end 
+0

您使用的设计来处理电子邮件确认? – alcedo

+0

不。我没有使用设计。 –

回答

0

我已经发现了一些错误:

你会放置一个link_to帮手文件夹:应用程序/视图/ *仅

所以如果你试图在html.erb文件放上,你应该能够看到链接生成

link_to 'Resend the activation link.', :action => "try_resend", :controller => "PasswordResets" 

的控制器:

class PasswordResets < ApplicationController 
    def try_resend 
    puts 'You should see this in console' 
    end 
end