首页 文章

部署到Heroku时无法使用db migrate

提问于
浏览
1

我试图将我的代码部署到heroku . 它只适用于

config.assets.initialize_on_precompile = false

在我的application.rb中,尽管我使用的是Rails 4.2.3 . 但是当我试图使用时

heroku运行rake db:migrate

它无法正常处理错误:

名称错误:主要的未定义局部变量或方法配置:''中的对象/app/config/application.rb:7

这是我的Gemfile

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
group :production do
#Use PG
gem 'pg'
end
group :development do
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
end
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0.1'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

#Use Heroku
gem 'rails_12factor', group: 'production'   
#Use bootstrap
gem 'bootstrap', '~> 4.0.0.alpha3'
gem 'autoprefixer-rails'
#Use Redcarpet
gem 'redcarpet'
#Use SQLite
#gem 'sqlite3', '1.3.11'


# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin]

这是application.rb

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

require 'rails/all'

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
# Prevent initializing the application before assets are precompiled (required for heroku)
config.assets.initialize_on_precompile = false
Bundler.require(*Rails.groups)
module Blog
  class Application < Rails::Application
    # Settings in config/environments/* take precedence over those specified here.
    # Application configuration should go into files in config/initializers
    # -- all .rb files in that directory are automatically loaded.

    # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
    # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
    # config.time_zone = 'Central Time (US & Canada)'

    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
    # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
    # config.i18n.default_locale = :de
  end
end

我的卡住点的任何解决方案?

我尝试的日志:git push heroku master with config.assets.initialize_on_precompile = false put in production.rb

http://i.stack.imgur.com/9rXp9.png

对不起,因为我是新手,我不能把img .

1 回答

  • 1

    从application.rb中删除 config.assets.initialize_on_precompile = false

    如果您需要在rails应用程序中使用此行,则应该输入: app/config/environments/production.rb

相关问题