Heroku拒绝来自Ruby on Rails app的推送

时间:2022-04-03 23:11:53

Right after running 'heroku run rake db:migrate', the error includes:

运行'heroku run rake db:migrate'后,错误包括:

    remote:        Bundle complete! 21 Gemfile dependencies, 77 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into ./vendor/bundle.

    remote: sh: 2: Syntax error: Unterminated quoted string
remote: sh: 2: Syntax error: Unterminated quoted string
remote:  !
remote:  !     Could not detect rake tasks
remote:  !     ensure you can run `$ bundle exec rake -P` against your app
remote:  !     and using the production group of your Gemfile.
remote:  !     rake aborted!
remote:  !     NameError: undefined local variable or method `config' for main:Object

remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to postil9.
remote: 
To https://git.heroku.com/postil9.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/postil9.git

And here's my 'production.rb' file:

这是我的'production.rb'文件:

Rails.application.configure do

  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local = false
  config.action_controller.perform_caching = true
  config.serve_static_files = ENV["RAILS_SERVE_STATIC_FILES"].present?
  config.assets.js_compressor = :uglifier
  config.assets.compile = false
  config.assets.digest = true
  config.log_level = :debug
  config.i18n.fallbacks = true
  config.active_support.deprecation = :notify
  config.log_formatter = ::Logger::Formatter.new
  config.active_record.dump_schema_after_migration = false
  config.action_mailer.default_url_options = { host: "postil9.herokuapp.com"}
  config.paperclip_defaults = {
  storage: :s3,
  s3_credentials: {
    bucket: ENV.fetch("S3_BUCKET_NAME"),
    access_key_id: ENV.fetch("AWS_ACCESS_KEY_ID"),
    secret_access_key: ENV.fetch("AWS_SECRET_ACCESS_KEY"),
    s3_region: ENV.fetch("AWS_REGION"),
  }
}

  Paperclip::Attachment.default_options[:s3_host_name] = "s3-us-west-2.amazonaws.com"

end

My application.rb file:

我的application.rb文件:

require File.expand_path('../boot', __FILE__)

config.assets.initialize_on_precompile = false
require 'rails/all'

Bundler.require(*Rails.groups)

module Workspace
  class Application < Rails::Application


    config.active_record.raise_in_transactional_callbacks = true
  end
end

Already tried bundle install --without production, but still have no clue about the solution. The app works perfectly on the Rails server.

已经尝试过捆绑安装 - 没有生产,但仍然没有解决方案的线索。该应用程序在Rails服务器上运行良好。

1 个解决方案

#1


1  

In your application.rb file you have :

在您的application.rb文件中,您有:

config.assets.initialize_on_precompile = false

And it's outside the application class and that's why it raising :

它在应用程序类之外,这就是它提升的原因:

NameError: undefined local variable or method `config' for main:Object

because 'config' doesn't exists outside the app class, your application.rb should look like this :

因为'config'在app类之外不存在,你的application.rb应如下所示:

require File.expand_path('../boot', __FILE__)

require 'rails/all'

Bundler.require(*Rails.groups)

module Workspace
  class Application < Rails::Application
    config.assets.initialize_on_precompile = false # Moved in app class
    config.active_record.raise_in_transactional_callbacks = true
  end
end

#1


1  

In your application.rb file you have :

在您的application.rb文件中,您有:

config.assets.initialize_on_precompile = false

And it's outside the application class and that's why it raising :

它在应用程序类之外,这就是它提升的原因:

NameError: undefined local variable or method `config' for main:Object

because 'config' doesn't exists outside the app class, your application.rb should look like this :

因为'config'在app类之外不存在,你的application.rb应如下所示:

require File.expand_path('../boot', __FILE__)

require 'rails/all'

Bundler.require(*Rails.groups)

module Workspace
  class Application < Rails::Application
    config.assets.initialize_on_precompile = false # Moved in app class
    config.active_record.raise_in_transactional_callbacks = true
  end
end