Search code examples
ruby-on-railsdeviseomniauth-twitter

Rails 6 heroku Precompiling assets failed


compile fail with rails and omniauth on heroku

remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        NoMethodError: undefined method `[]' for nil:NilClass
remote:        /tmp/build_f21d4b6cc71ba2ef116eca0b20a72d4b/config/initializers/devise.rb:263:in `block in <main>'
remote:        /tmp/build_f21d4b6cc71ba2ef116eca0b20a72d4b/vendor/bundle/ruby/2.7.0/gems/devise-4.7.1/lib/devise.rb:311:in `setup'
remote:        /tmp/build_f21d4b6cc71ba2ef116eca0b20a72d4b/config/initializers/devise.rb:5:in `<main>'

I follow the devise .rb to 263 which is where I add twitter omniauth

config.omniauth :twitter, Rails.application.credentials.twitter[:app_id], Rails.application.credentials.twitter[:app_secret]

I am storing my credentials stored in config/credentials.yml.enc


Solution

  • The problem was caused by not being able to access the credentials.yml in production. We could access the master key value in production as it is not committed.

    I fixed the issue by adding the master.key-value in Heroku, under settings, config vars master key