预编译资产失败的Rails

时间:2013-11-11 23:56:46

标签: ruby-on-rails heroku precompile

我在Heroku上部署Rails 4.0.1但是当我尝试预编译时出现以下错误:

$ rake assets:precompile
rake aborted!
uninitialized constant SampleApp
c:/Sites/sampleapp/config/initializers/secret_token.rb:27:in `<top (required)>'
c:/Sites/sampleapp/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace)

这是我的environment.rb:

# Load the Rails application.
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
Sampleapp::Application.initialize!

secret_token中发现问题的行:

SampleApp::Application.config.secret_key_base = secure_token

这是我的application.rb:

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

# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"

Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env)

module Sampleapp
  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

1 个答案:

答案 0 :(得分:0)

根据application.rb,您的项目使用Sampleapp作为其名称。因此,请确保所有核心文件在选项配置中使用相同的名称 - ,包括大写

# config/initializers/secret_token.rb
Sampleapp::Application.config.secret_key_base = secure_token