我有一条flash消息,我想为其添加一个link_to标记,以便用户可以在flash消息中添加一个链接。我的问题是我得到错误未定义的方法`link_to'。
sessions_controller.rb
def create
user = User.find_by_email(params[:sessions][:email].downcase)
if user.activated?
//Log User In
else
flash[:warning] = "Account not activated. Check your email for the activation link. #{link_to('Resend Activation Email', user.send_activation_email)}"
redirect_to root_url
end
flash[:warning] = "Account not activated. Check your email for the activation link. #{link_to('Resend Activation Email', user.send_activation_email)}"
end
是否可以在控制器方法中添加link_to?
答案 0 :(得分:1)
您可以使用:
ActionController::Base.helpers.link_to('Resend Activation Email', user.send_activation_email)