我试图将facebook身份验证与设计集成。
我使用了本教程(http://sourcey.com/rails-4-omniauth-using-devise-with-twitter-facebook-and-linkedin)并让它在本地工作,但是当我推送到heroku时我一直收到错误。我已经将Facebook dev / apps部分中的链接更改为实际域。
我在production.rb
中有以下代码。对于" app_domain"部分,我试图提出所有类型的应用程序域变体(域名,domain.com,heroku应用程序名称等),但我不知道应该去哪里。
我是一名新编码员,所以非常感谢任何帮助!
# Email for omniauth facebook auth
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => config.app_domain }
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: '587',
enable_starttls_auto: true,
user_name: 'someuser',
password: 'somepass',
authentication => :plain,
domain => 'somedomain.com'
}
NoMethodError:未定义的方法`app_domain'对
/tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/railtie/configuration.rb:95:in
method_missing' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/config/environments/production.rb:100:in
阻止' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/railtie.rb:210:ininstance_eval' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/railtie.rb:210:in
配置&#39; /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/config/environments/production.rb:1:in<top (required)>' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in
需要&#39; /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inblock in require' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:in
load_dependency&#39 ; /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inrequire' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/engine.rb:594:in
块(2在&#39; /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/engine.rb:593:ineach' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/engine.rb:593:in
阻止&#39; /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/initializable.rb:30:ininstance_exec' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/initializable.rb:30:in
运行&#39; /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/initializable.rb:55:inblock in run_initializers' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/initializable.rb:44:in
各&#39; /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/initializable.rb:44:intsort_each_child' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/initializable.rb:54:in
run_initializers&#39; /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/application.rb:288:ininitialize!' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/config/environment.rb:5:in
&#39; /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:inrequire' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in
阻止在需要& #39; /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:232:inload_dependency' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in
要求&#39 ; /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/application.rb:264:in run_tasks_blocks中的require_environment!' /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/railties-4.1.1/lib/rails/application.rb:367:in
阻止&#39; /tmp/build_9557c4b1-3f72-41e9-bc67-afe937d8b044/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:55:in `定义&#39;中的块(2级) 任务:TOP =&gt;环境 (通过使用--trace运行任务查看完整跟踪)! !预编译资产失败。
答案 0 :(得分:1)
您的错误消息“未定义的方法`app_domain'”源自此行:
config.action_mailer.default_url_options = { :host => config.app_domain }
正如它所说,您尚未在app_domain
选项上分配config
属性。 Action Mailer是发送电子邮件的Rails的一部分,它使用此设置生成返回应用程序的链接。
您只需将config.app_domain = "myapp.herokuapp.com"
添加到config/environments/production.rb
文件的顶部即可。但这是硬编码的;另一种方法是使用环境变量。
Heroku uses their config
command for this;在终端中运行heroku config:set APP_DOMAIN=myapp.herokuapp.com
进行设置,然后在Ruby应用程序中使用ENV['APP_DOMAIN']
来访问它。所以你的配置行看起来像这样:
config.action_mailer.default_url_options = { :host => ENV['APP_DOMAIN'] }
最后,您将domain
设置作为底部smtp_settings
块的一部分。您可能也希望使用新设置。