Heroku拒绝了Ruby on Rails应用程序的推送



在运行"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

这是我的"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

我的应用程序.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

已经尝试过捆绑安装 - 没有生产,但仍然不知道解决方案。 该应用程序在Rails服务器上完美运行。

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

config.assets.initialize_on_precompile = false

它在应用程序类之外,这就是为什么它提出:

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

由于"config"在应用程序类之外不存在,因此您的应用程序.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

最新更新