Рельсы4 звездочки; Логический путь актива не имеет расширения

Недавно я обновился до Rails 4, и во время выполнения спецификаций запроса я начал получать следующую ошибку:

Сбой/ошибка: невозможно найти соответствующую строку из обратной трассировки Sprockets::ArgumentError: логический путь актива не имеет расширения: europe

Есть ли способ заставить Sprockets принимать файлы без расширения?

Драгоценные камни: Звездочки: 2.10.1 Рельсы: 4.0.2

в файле config/application.rb добавьте


person tblakey89    schedule 31.12.2013    source источник
comment
Спасибо, это действительно помогло.   -  person Serabe    schedule 31.12.2013


Ответы (2)


так это выглядит

initializer 'setup_asset_pipeline', :group => :all  do |app|
  # We don't want the default of everything that isn't js or css, because it pulls too many things in
  app.config.assets.precompile.shift

  # Explicitly register the extensions we are interested in compiling
  app.config.assets.precompile.push(Proc.new do |path|
    File.extname(path).in? [
      '.html', '.erb', '.haml',                 # Templates
      '.png',  '.gif', '.jpg', '.jpeg',         # Images
      '.eot',  '.otf', '.svc', '.woff', '.ttf', # Fonts
    ]
  end)
end

Чтобы предварительно скомпилировать активы, вам нужно переместить любые файлы без расширений из app/assets в vendor/assets. Это известная проблема со звездочками, и у Bower есть предупреждение об этом в их файле readme, см. https://github.com/stve/bower/pull/4/files

module ProjectName
  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
    initializer 'setup_asset_pipeline', :group => :all  do |app|
      # We don't want the default of everything that isn't js or css, because it pulls too many things in
      app.config.assets.precompile.shift

      # Explicitly register the extensions we are interested in compiling
      app.config.assets.precompile.push(Proc.new do |path|
        File.extname(path).in? [
          '.html', '.erb', '.haml',                 # Templates
          '.png',  '.gif', '.jpg', '.jpeg',         # Images
          '.eot',  '.otf', '.svc', '.woff', '.ttf', # Fonts
        ]
      end)
    end
  end
end
person MZaragoza    schedule 08.08.2014
comment
@rodrigoalves я рад, что смог помочь - person ; 12.12.2014
comment
Цитата # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/asset.rb:36:in _1_new' # /usr/local/rvm/gems/ ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/base.rb:380:in _2_block in build_asset' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems /sprockets-2.10.1/lib/sprockets/caching.rb:58:in _3_build_asset' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/ base.rb:287:in _4_find_asset' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/server.rb:47:in _5_block in call' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/journey/router.rb:59:in _6_call' # /usr/local/rvm/gems /ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:680:in _7_call' # /usr/local/rvm/gems/ruby-1.9.3-p448/ gems/rack-1.5.2/lib/rack/conditionalget.rb:25:in _8_call' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/remotipart-1.2.1/lib/remotipart /середина dleware.rb:27:in _9_call' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/middleware/flash.rb:241:in _10_context' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in _11_call' # /usr/local/rvm /gems/ruby-1.9.3-p448/gems/activerecord-4.0.2/lib/active_record/query_cache.rb:36:in _12_call' # /usr/local/rvm/gems/ruby-1.9.3-p448/ gems/actionpack-4.0.2/lib/action_dispatch/middleware/callbacks.rb:29:in _13_run_515869138317914613_call_callbacks' # /usr/local/rvm/gems /ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in _14_call' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/ actionpack-4.0.2/lib/action_dispatch/middleware/remote_ip.rb:76:in _15_call' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch /middleware/show_exceptions.rb:30:in _16_call_app' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/railties- 4.0.2/lib/rails/rack/logger.rb:20:in _17_block в tagged' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support /tagged_logging.rb:25:in _18_tagged' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/rack/logger.rb:20:in _19_call ' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in _20_call' # /usr/local/rvm/gems/ ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/cache/strategy/local_cache.rb:83:in _21_call' # /usr/local/rvm/gems/ruby-1. 9.3-p448/gems/rack-1.5.2/lib/rack/sendfile.rb:112:in _22_call' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2 /lib/rails/application.rb:97:in _23_call' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/urlmap.rb:65: in _24_each' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in _25_call' # /usr/local/rvm/ gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:in _26_service' # /usr/local/rvm/rubies/ruby-1.9.3-p448 /lib/ruby/1.9.1/webrick/httpserver.rb:94:in _27_block в start_thread' - person MZaragoza; 24.04.2015

Или вы можете убедиться, что все файлы в app/assets имеют расширение, но это требует больше времени.

Посмотрите на эту проблему

person ObjectNameDisplay    schedule 12.03.2015