如何使用Heroku和Send Grid发送电子邮件激活链接?

时间:2018-01-17 08:04:39

标签: ruby-on-rails ruby git heroku sendgrid

当我尝试发送电子邮件激活链接时,heroku日志中的错误:

  

2018-01-17T07:37:09.783615 + 00:00 app [web.1]:   [f3c128f0-83ad-4879-ae6c-a54b28030290] [1m [35m(0.7ms)[0m]   [1分[35mBEGIN [0米       2018-01-17T07:37:09.891482 + 00:00 app [web.1]:[f3c128f0-83ad-4879-ae6c-a54b28030290]已完成500内部服务器   188ms错误(ActiveRecord:10.7ms)       2018-01-17T07:37:09.892707 + 00:00 app [web.1]:[f3c128f0-83ad-4879-ae6c-a54b28030290]
      2018-01-17T07:37:09.871499 + 00:00 app [web.1]:[f3c128f0-83ad-4879-ae6c-a54b28030290] [1m [35m(1.1ms)[0m]   [1分[31mROLLBACK [0米       2018-01-17T07:37:09.892886 + 00:00 app [web.1]:[f3c128f0-83ad-4879-ae6c-a54b28030290] NoMethodError(未定义方法)   activation_digest = for#       2018-01-17T07:37:09.892887 + 00:00 app [web.1]:你的意思是? activation_token =):       2018-01-17T07:37:09.892920 + 00:00 app [web.1]:[f3c128f0-83ad-4879-ae6c-a54b28030290]
      2018-01-17T07:37:09.892966 + 00:00 app [web.1]:[f3c128f0-83ad-4879-ae6c-a54b28030290] app / models / user.rb:71:in   create_activation_digest       2018-01-17T07:37:09.892967 + 00:00 app [web.1]:[f3c128f0-83ad-4879-ae6c-a54b28030290]   app / controllers / users_controller.rb:23:在`create'       2018-01-17T07:37:09.892966 + 00:00 heroku [router]:at = info method = POST path =" / users"主机= letsgo228.herokuapp.com   request_id = f3c128f0-83ad-4879-ae6c-a54b28030290 fwd =" 61.6.75.149"   dyno = web.1 connect = 1ms service = 194ms status = 500 bytes = 1891   协议= HTTPS       2018-01-17T07:37:10.572375 + 00:00 heroku [router]:at = info method = GET path =" /favicon.ico"主机= letsgo228.herokuapp.com   request_id = 6b2a9847-7844-4ae9-a7df-e1405b86b08f fwd =" 61.6.75.149"   dyno = web.1 connect = 0ms service = 1ms status = 304 bytes = 112 protocol = https

用户模型

 # Creates and assigns the activation token and digest.
  def create_activation_digest
    self.activation_token  = User.new_token
    self.activation_digest = User.digest(activation_token)
  end
end

user_contrller

def new
    @user = User.new
  end

  def create
    @user = User.new(user_params)
    if @user.save
      @user.send_activation_email
      flash[:info] = "Пожалуйста проверьте свою почту,в течении 1 минуты придет письмо для активации аккаунта"
      redirect_to root_url
    else
      render 'new'
    end
  end

1 个答案:

答案 0 :(得分:1)

您的用户模型上没有名为activation_digest的列。 rails g migration add_activation_digest_to_users activation_digest:string:index