0

Rails:2.3.7 Ruby:1.8.7 我想更改重置密码 URL。我在 development.RB 中设置了默认 URL,但它显示 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

发展.rb

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

O/p

    Date: Tue, 8 Aug 2017 16:50:25 +0530
To: ronakbhatt@yopmail.com
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.
4

1 回答 1

1

将以下代码添加到

应用程序控制器

def url_email_reset_password

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

结尾

于 2017-08-10T05:10:52.037 回答