我在本地机器中安装了设备gem。一切都是有效的。但后来我把我的应用程序转移到了Heroku,我得到了那个错误,然后创建了新的用户
Email translation missing:
ru.activerecord.errors.models.user.attributes.email.taken
我建议存在配置/环境/生产.rb 文件的问题
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
发生这种情况是因为您的语言设置。请检查您的config/locates/device.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']
}
对于heroku,您必须为邮件程序设置sendgrid
。
使用更改生产中的mailer配置
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']
}