0

如果我在生产模式下使用rails s -e production获取错误作为

Unsupported rails environment for compass
/home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/railties-4.0.0/lib/rails/railtie/configuration.rb:95:in `method_missing': undefined method `asset' for #<Rails::Application::Configuration:0x93d2468> (NoMethodError)
    from /home/user/Documents/site/mysite/config/application.rb:41:in `<class:Application>'
    from /home/user/Documents/site/mysite/config/application.rb:18:in `<module:Admin>'
    from /home/user/Documents/site/mysite/config/application.rb:17:in `<top (required)>'
    from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/railties-4.0.0/lib/rails/commands.rb:76:in `require'
    from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/railties-4.0.0/lib/rails/commands.rb:76:in `block in <top (required)>'
    from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
    from /home/user/.rvm/gems/ruby-2.0.0-p247@global/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

这是我的application.rb

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

# require 'rails/all'

# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
# require "active_resource/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, :assets, Rails.env)

module Admin
  class Application < Rails::Application

     # Configure the default encoding used in templates for Ruby 1.9.
    config.encoding = "utf-8"

    # Configure sensitive parameters which will be filtered from the log file.
    config.filter_parameters += [:password]

    # Enable escaping HTML in JSON.
    config.active_support.escape_html_entities_in_json = true

    # Use SQL instead of Active Record's schema dumper when creating the database.
    # This is necessary if your schema can't be completely dumped by the schema dumper,
    # like if you have constraints or database-specific column types
    # config.active_record.schema_format = :sql

    # Enforce whitelist mode for mass assignment.
    # This will create an empty whitelist of attributes available for mass-assignment for all models
    # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
    # parameters by using an attr_accessible or attr_protected declaration.
    config.active_record.whitelist_attributes = true

    # Enable the asset pipeline
    config.asset.enable = true

    # Version of your assets, change this if you want to expire all your assets
    config.assets.version = '1.0'

    # 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
4

1 回答 1

1

你只是有一个错字 - 它应该是config.assets.enable,不是config.asset.enable

有关详细信息,请参阅http://guides.rubyonrails.org/asset_pipeline.html#what-is-the-asset-pipeline-questionmark

于 2013-10-20T07:19:01.023 回答