jeudi 10 décembre 2015

How to add class in controller

I want to add a class in controller. to change the color of message that appears in notice of if function

This is my controller

def send_password
    @user=User.find_by_email(params[:user][:email])
    if @user.present?
      @user.send_reset_password_instructions
      flash[:notice] = "Reset password instructions have been sent to #{@user.email}."
      redirect_to reset_password_path, notice: "Reset password instructions have been sent to #{@user.email}."
    else
      return redirect_to reset_password_path, notice: "User is not available."
    end
  end
end

Please help.

i tried like this in form i given like this ,but not working.

<%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: {method: :post}) do |f| %> <% if f.error_notification == 'User is not available' %> <h1 class='reset-error-message'><%= f.error_notification %></h1> <% else %> <h1 class='reset-success-message'><%= f.error_notification %></h1> <% end %>

then in controller i tried like this also but then also not working

if @user.present? @user.send_reset_password_instructions flash[:notice] = "Reset password instructions have been sent to #{@user.email}." redirect_to reset_password_path, notice: "Reset password instructions have been sent to #{@user.email}.",class:"reset-success-message" else return redirect_to reset_password_path, notice: "User is not available., class:"reset-error-message" end

Aucun commentaire:

Enregistrer un commentaire