I have a controller method for login my app like this:
def create
user = User.find_by(mail: params[:session][:mail].downcase)
if user && user.authenticate(params[:session][:password])
if user.confirmed?
# Stuff when login is OK
.......
else
logout
text = I18n.t("error.login.confirmation", :link => ActionController::Base.helpers.link_to(I18n.t("button"), confirm_user_path(user), :class => 'btn btn-info'))
@result = ActionController::Base.helpers.sanitize(text, :tags => ['br','a']).html_safe
respond_to do |format|
format.html { render 'new' }
format.js { @result.html_safe }
end
end
# more stuff
.......
end
end
If the user has not confirmed the email, I want to show him a message with a link to re-send the confirmation mail:
Please confirm your signup. <br /> <br /> <a class="btn btn-info" href="/users/48/confirm_user">Re-send confirmation mail.</a>
UPDATE: This is how render the view
$("p.bg-danger").html("<%= @result %>")