Heroku отклоняет пуш из приложения Ruby on Rails - PullRequest
0 голосов
/ 29 мая 2018

Сразу после запуска '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 file:

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.

1 Ответ

0 голосов
/ 29 мая 2018

В вашем файле application.rb у вас есть:

config.assets.initialize_on_precompile = false

И он находится вне класса приложения, и поэтому он поднимается:

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

, потому что «config» не существуетвне класса приложения ваш 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
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...