Ronak Bhatt
Ronak Bhatt

Reputation: 162

Change Reset password url in Rails 2

Rails:2.3.7 Ruby:1.8.7 I want to change reset password URL. I set default URL in development.RB but it shows localhost.

  def create
    @user = User.find_by_email(params[:email])
    if @user
      @user.deliver_perishable_email!(:password_reset_instructions)
      flash[:notice] = "Check your email for password reset instructions."
      redirect_to root_url
    else
      flash[:notice] = "No user was found with that email address."
      render :action => :new
    end
  end

Development.rb

config.action_mailer.default_url_options = { :host => "http://*****.com" }

O/p

    Date: Tue, 8 Aug 2017 16:50:25 +0530
To: [email protected]
Subject: Your [Pyromaniac] password reset instructions
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8

A request to reset your password has been made. If you did not make this request, simply ignore this email. If you did make this request just click the link below:


http://localhost:3000/password_resets/NgaNMcvuJ_2D1Ol4nF4A/edit


If the above URL does not work try copying and pasting it into your browser. If you continue to have the problem, please feel free to contact us.

Upvotes: 0

Views: 251

Answers (1)

Pankaj
Pankaj

Reputation: 160

Add the below code in

Application_controller

def url_email_reset_password

 ActionMailer::Base.default_url_options[:host] pointing to localhost:3000

end

Upvotes: 1

Related Questions