bundle exec rake assets:precompile - database configuration does not specify adapter

后端 未结 7 1904
梦毁少年i
梦毁少年i 2020-12-16 18:54

After 24 hours of trying to find the problem with my app. I finally found the problem.

I ran

rake assets:precompile RAILS_ENV=production

相关标签:
7条回答
  • 2020-12-16 19:35

    What worked for me was this:

    rake assets:precompile RAILS_ENV=production

    Access your server via ssh and type that command in, it should do the trick.

    0 讨论(0)
  • 2020-12-16 19:38

    call rake assets:precompile:all

    0 讨论(0)
  • 2020-12-16 19:42

    Do this:

    development:
      adapter: postgresql
      host: localhost
      encoding: unicode
      database: ndoda_development
      pool: 5
      username:
      password:
    
    test:
      adapter: postgresql
      encoding: unicode
      database: ndoda_test
      pool: 5
    
    # Add the below...
    
    production:
      adapter: postgresql
      host: localhost
      encoding: unicode
      database: ndoda_production
      pool: 5
      username:
      password:
    

    Heroku will overwrite your database.yml with its own version, regardless of what you put in there. However, your rake task running in the Production environment requires a variable, so give it a dummy one.

    As noted above, you can also add 'config.assets.initialize_on_precompile = false' to your production.rb. If set, Heroku requires it be set to 'false'.

    0 讨论(0)
  • 2020-12-16 19:43

    This should work: rake assets:precompile RAILS_ENV=development

    It tries to load up your production environment, when your database.yml doesn't include it.

    0 讨论(0)
  • 2020-12-16 19:49

    The simple solution was to add one simple line to my application.rb

    config.assets.initialize_on_precompile = false
    

    And everything works.

    0 讨论(0)
  • 2020-12-16 19:53

    Make sure you have some dummy production entry in your local config/database.yml file

    production:
      <<: *default
      database: your_local_database_name
    

    I've come across the same error in 2016 with Rails 4.2.6 and Capistrano 3.4. We were precompiling the assets during the deploy script just before uploading them together with the code, but rake assets:precompile needs some production entry, even if it's just a dummy one. Source: https://github.com/TalkingQuickly/capistrano-3-rails-template/issues/12

    0 讨论(0)
提交回复
热议问题