my rails app works in development mode on my mac. Whrn i try to compile into heroku i get errors on the command line
我的rails应用程序在我的Mac上以开发模式运行。当我尝试编译成heroku时,我在命令行上遇到错误
Cleaning up the bundler cache.
Removing bundler (1.3.2)
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
undefined method `[]' for nil:NilClass
/tmp/build_9afd2a8f-0be9-427c-82f9-5431cf3a30fc/config/initializers/devise.rb:234:in `block in <top (required)>'
/tmp/build_9afd2a8f-0be9-427c-82f9-5431cf3a30fc/vendor/bundle/ruby/2.0.0/gems/devise-3.1.2/lib/devise.rb:276:in `setup'
/
/tmp/build_9afd2a8f-0be9-427c-82f9-5431cf3a30fc/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc1/lib/rails/engine.rb:609:in `bl
/tmp/build_9afd2a8f-0be9-427c-82f9-5431cf3a30fc/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc1/lib/rails/application.rb:214:in `initialize!'
/tmp/build_9afd2a8f-0be9-427c-82f9-5431cf3a30fc/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.rc1/lib/rails/railtie/configurable.rb:30:in `method_missing'
/tmp/build_9afd2a8f-0be9-427c-82f9-5431cf3a30fc/config/environment.rb:5:in `<top (required)>'
/tmp/build_9afd2a8f-0be9-427c-82f9-5431cf3a30fc/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.rc1/lib/active_support/dependencies.rb:228:in `require'
/tmp/build_9afd2a8f-0be9-427c-82f9-5431cf3a30fc/vendor/bundle/ruby/2.0.0/gems/activesupport-
Tasks: TOP => environment
(See full trace by running task with --trace)
!
! Precompiling assets failed.
!
! Push rejected, failed to compile Ruby app
checked my devise.rb the only line i added was
检查了我的devise.rb我添加的唯一一行是
config.omniauth :facebook, FACEBOOK_CONFIG['facebook_api_key'], FACEBOOK_CONFIG['facebook_api_secret'], scope: "email, publish_actions"
and this is my gemfile - as you can see i have the production and development information included
group :development, :test do
gem 'sqlite3'
end
group :production do
gem 'pg'
gem 'rails_12factor'
end
as advised devise 230-238
如建议设计230-238
# ==> OmniAuth
# Add a new OmniAuth provider. Check the wiki for more information on setting
# up on your models and hooks.
config.omniauth :facebook, FACEBOOK_CONFIG['facebook_api_key'], FACEBOOK_CONFIG['facebook_api_secret'], scope: "email, publish_actions"
# ==> Warden configuration
# If you want to use other strategies, that are not supported by Devise, or
# change the failure app, you can configure them inside the config.warden block.
4 个解决方案
#1
0
You probably want to stop using this magick FACEBOOK_CONFIG
variable and start using environment variables for heroku
您可能希望停止使用此magick FACEBOOK_CONFIG变量并开始使用heroku的环境变量
config.omniauth :facebook, ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_API_SECRET'], scope: "email, publish_actions"
to get this ENV working on development easier please check: https://github.com/bkeepers/dotenv or https://github.com/laserlemon/figaro
为了让这个ENV更容易开发,请查看:https://github.com/bkeepers/dotenv或https://github.com/laserlemon/figaro
#2
0
It looks like the issue is with Devise. the error says
看起来像是Devise的问题。错误说
undefined method `[]' for nil:NilClass
If you look at the next line down it is coming from.
如果你看下一行,它来自。
config/initializers/devise.rb:234
So the error is on line 234 in config/initializers/devise.rb.
所以错误在config / initializers / devise.rb的第234行。
Run the following command on your mac.
在mac上运行以下命令。
bundle exec rake assets:precompile
If you don't get the same error, then you know that it is an issue with your production environment.
如果您没有收到相同的错误,那么您知道这是您的生产环境的问题。
Can you add what you have on line config/initializers/devise.rb:234
你能在线路config / initializers / devise.rb上添加你的东西:234
#3
0
Obviously FACEBOOK_CONFIG
that you're trying to use is nil
.
很明显,你试图使用的FACEBOOK_CONFIG是零。
First you have to set the two environment variables in your Heroku account:
首先,您必须在Heroku帐户中设置两个环境变量:
$ heroku config:set FACEBOOK_API_KEY=your-key-here
$ heroku config:set FACEBOOK_API_SECRET=your-secret-here
Then verify these are set correctly:
然后验证这些设置是否正确:
$ heroku config:get FACEBOOK_API_KEY
$ heroku config:get FACEBOOK_API_SECRET
Finally update the device.rb
file as follows:
最后更新device.rb文件,如下所示:
config.omniauth :facebook, ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_API_SECRET'], scope: "email, publish_actions"
Now should be good to go.
现在应该好好去。
#4
0
Just update your facebook.yml file with same information for production. I guess you only have development.
只需使用相同的生产信息更新您的facebook.yml文件即可。我想你只有发展。
/config/facebook.yml
/config/facebook.yml
development:
facebook_api_key: copy_from_here
facebook_api_secret: copy_2_from_here
production:
facebook_api_key: paste_to_here
facebook_api_secret: paste_2_here
#1
0
You probably want to stop using this magick FACEBOOK_CONFIG
variable and start using environment variables for heroku
您可能希望停止使用此magick FACEBOOK_CONFIG变量并开始使用heroku的环境变量
config.omniauth :facebook, ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_API_SECRET'], scope: "email, publish_actions"
to get this ENV working on development easier please check: https://github.com/bkeepers/dotenv or https://github.com/laserlemon/figaro
为了让这个ENV更容易开发,请查看:https://github.com/bkeepers/dotenv或https://github.com/laserlemon/figaro
#2
0
It looks like the issue is with Devise. the error says
看起来像是Devise的问题。错误说
undefined method `[]' for nil:NilClass
If you look at the next line down it is coming from.
如果你看下一行,它来自。
config/initializers/devise.rb:234
So the error is on line 234 in config/initializers/devise.rb.
所以错误在config / initializers / devise.rb的第234行。
Run the following command on your mac.
在mac上运行以下命令。
bundle exec rake assets:precompile
If you don't get the same error, then you know that it is an issue with your production environment.
如果您没有收到相同的错误,那么您知道这是您的生产环境的问题。
Can you add what you have on line config/initializers/devise.rb:234
你能在线路config / initializers / devise.rb上添加你的东西:234
#3
0
Obviously FACEBOOK_CONFIG
that you're trying to use is nil
.
很明显,你试图使用的FACEBOOK_CONFIG是零。
First you have to set the two environment variables in your Heroku account:
首先,您必须在Heroku帐户中设置两个环境变量:
$ heroku config:set FACEBOOK_API_KEY=your-key-here
$ heroku config:set FACEBOOK_API_SECRET=your-secret-here
Then verify these are set correctly:
然后验证这些设置是否正确:
$ heroku config:get FACEBOOK_API_KEY
$ heroku config:get FACEBOOK_API_SECRET
Finally update the device.rb
file as follows:
最后更新device.rb文件,如下所示:
config.omniauth :facebook, ENV['FACEBOOK_API_KEY'], ENV['FACEBOOK_API_SECRET'], scope: "email, publish_actions"
Now should be good to go.
现在应该好好去。
#4
0
Just update your facebook.yml file with same information for production. I guess you only have development.
只需使用相同的生产信息更新您的facebook.yml文件即可。我想你只有发展。
/config/facebook.yml
/config/facebook.yml
development:
facebook_api_key: copy_from_here
facebook_api_secret: copy_2_from_here
production:
facebook_api_key: paste_to_here
facebook_api_secret: paste_2_here