【问题标题】:Rails settings of devise设计的 Rails 设置
【发布时间】:2015-03-20 07:19:02
【问题描述】:

我在本地机器上安装了 devise gem。一切正常。但是后来我将我的应用程序转移到 Heroku 我得到了那个错误,然后创建新用户

Email translation missing: 
ru.activerecord.errors.models.user.attributes.email.taken

我建议问题是有文件 config/environment/production.rb

config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }

【问题讨论】:

    标签: ruby-on-rails ruby heroku devise


    【解决方案1】:

    这是因为您的语言设置。 请检查您的 config/locales/devise.ru.yml

    ru: 
      activerecord:
        errors: 
          models  : 
            user: 
              attributes: 
                email: 
                  taken: "Whatever you want"  
    

    如果你觉得这是因为 sendgrid 而发生的,那么请像下面这样设置

    config.action_mailer.asset_host = "YOUR-URL"
    config.action_mailer.default_url_options = { :host => "YOUR-URL", :only_path => false }
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
    :address        => "smtp.sendgrid.net",
    :port           => "25",
    :authentication => :plain,
    :user_name      => ENV['SENDGRID_USERNAME'],
    :password       => ENV['SENDGRID_PASSWORD'],
    :domain         => ENV['SENDGRID_DOMAIN']
    

    }

    【讨论】:

    • 你是对的。问题出在 config/locales/devise.ru.yml
    【解决方案2】:

    对于heroku,您必须为邮件设置sendgrid

    在生产中更改您的邮件配置

    config.log_formatter = ::Logger::Formatter.new
      config.action_mailer.default_url_options = { :host => 'your-domain' }
      ActionMailer::Base.smtp_settings = {
          :address        => "smtp.sendgrid.net",
          :port           => "25",
          :authentication => :plain,
          :user_name      => ENV['SENDGRID_USERNAME'],
          :password       => ENV['SENDGRID_PASSWORD'],
          :domain         => ENV['SENDGRID_DOMAIN']
      }
    

    【讨论】:

    • sendgrid 是商业的。有非商业邮件吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-21
    • 1970-01-01
    • 1970-01-01
    • 2012-11-26
    相关资源
    最近更新 更多