我最近升级到了rails 4,在运行我的请求规范时,出现了以下错误:
失败/错误:无法从回溯中找到匹配的行
链轮::参数错误:
资产逻辑路径没有扩展:欧洲
blockquote/usr/local/rvm/gems/ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/asset.rb:36:ininitialize' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/base.rb:380:innew'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/base.rb:380:inbuild_asset' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/index.rb:94:inblock-in-build撸asset
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/caching.rb:58:incache_asset' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/index.rb:93:in构建资产'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/base.rb:287:infind_asset' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/index.rb:61:in查找资产'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/sprockets-2.10.1/lib/sprockets/server.rb:47:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/journey/router.rb:71:in阻止调用'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action-dispatch/journey/router.rb:59:ineach' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/journey/router.rb:59:incall'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action-dispatch/routing/route-set.rb:680:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/etag.rb:23:in呼叫
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/conditionalget.rb:25:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/head.rb:11:in调用'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/remotipart-1.2.1/lib/remotipart/middleware.rb:27:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/middleware/params_parser.rb:27:in调用
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action-dispatch/middleware/flash.rb:241:在call' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in上下文中
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/middleware/cookies.rb:486:in调用
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/active record-4.0.2/lib/active_record/query_cache.rb:36:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:626:incall'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action-dispatch/middleware/callbacks.rb:29:inblock in call' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:373:in运行调用回调
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/active support-4.0.2/lib/active-cuu-support/callbacks.rb:80:inrun_callbacks' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/middleware/callbacks.rb:27:incall'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action-dispatch/middleware/remote-ip.rb:76:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/middleware/debug_exceptions.rb:17:incall'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/middleware/show_exceptions.rb:30:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/rack/logger.rb:38:incall_app'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/rack/logger.rb:20:inblock in call' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:67:inblock-in-taged'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/active support-4.0.2/lib/active-support/tagged-logging.rb:25:intagged' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:67:intagged'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/rack/logger.rb:20:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/middleware/request_id.rb:21:incall'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/runtime.rb:17:in调用
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/active support-4.0.2/lib/active_-support/cache/strategy/local_-cache.rb:83:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/actionpack-4.0.2/lib/action_dispatch/middleware/static.rb:64:incall'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/sendfile.rb:112:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/engine.rb:511:in调用
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/railties-4.0.2/lib/rails/application.rb:97:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/builder.rb:138:in调用
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/urlmap.rb:65:inblock in call' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/urlmap.rb:50:in每个
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/urlmap.rb:50:incall' # /usr/local/rvm/gems/ruby-1.9.3-p448/gems/capybara-2.2.0/lib/capybara/server.rb:19:incall'
#/usr/local/rvm/gems/ruby-1.9.3-p448/gems/rack-1.5.2/lib/rack/handler/webrick.rb:60:inservice' # /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:138:in服务
#/usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/httpserver.rb:94:inrun' # /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/webrick/server.rb:191:inblock-in-start-thread'
有没有办法让链轮接受没有扩展名的文件?
宝石:
链轮:2.10.1
钢轨:4.0.2

最佳答案

在config/application.rb文件中添加

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

所以看起来
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

关于ruby - Rails4 sprockets ; Assets 逻辑路径没有扩展名,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20856247/

10-13 05:28