3

更新

这是我的应用程序中“资产”的搜索结果(不包括日志)。

./app/assets/javascripts/application.js:4:// 此目录中的任何 JavaScript/Coffee 文件,lib/assets/javascripts,vendor/assets/javascripts,

./app/assets/javascripts/application.js:5:// 或 vendor/assets/javascripts 的插件,如果有的话,可以在这里使用相对路径来引用。

./app/assets/stylesheets/application.css:5: * 此目录中的任何 CSS 和 SCSS 文件、lib/assets/stylesheets、vendor/assets/stylesheets、

./app/assets/stylesheets/application.css:6: * 或插件的供应商/资产/样式表,如果有的话,可以在这里使用相对路径引用。

./config/application.rb:7: # 如果您在部署到生产环境之前预编译资产,请使用此行

./config/application.rb:8: Bundler.require(*Rails.groups(:assets => %w(开发测试)))

./config/application.rb:9: # 如果你想让你的资产在生产中延迟编译,使用这一行

./config/application.rb:10: # Bundler.require(:default, :assets, Rails.env)

./config/application.rb:54: # 启用资产管道

./config/application.rb:55: config.assets.enabled = true

./config/application.rb:57: # 您的资产版本,如果您想使所有资产过期,请更改此项

./config/application.rb:58: config.assets.version = '1.0'

./config/environments/development.rb:9: config.assets.enabled = false

./config/environments/development.rb:34: # 不压缩资源

./config/environments/development.rb:35: config.assets.compress = false ./config/environments/development.rb:37: # 展开加载资产的行

./config/environments/development.rb:38: config.assets.debug = true

./config/environments/production.rb:11: # 禁用 Rails 的静态资源服务器(Apache 或 nginx 已经这样做了)

./config/environments/production.rb:12:config.serve_static_assets = true

./config/environments/production.rb:15: config.assets.compress = true

./config/environments/production.rb:17: # 如果预编译资产丢失,不要回退到资产管道

./config/environments/production.rb:18: config.assets.compile = true

./config/environments/production.rb:20: # 为资产 URL 生成摘要

./config/environments/production.rb:21: config.assets.digest = true

./config/environments/production.rb:23: # 默认为 Rails.root.join("public/assets")

./config/environments/production.rb:24: # config.assets.manifest = YOUR_PATH

./config/environments/production.rb:45: # 启用来自资产服务器的图像、样式表和 JavaScript 服务

./config/environments/production.rb:46: # config.action_controller.asset_host = " http://assets.example.com "

./config/environments/production.rb:48: # 预编译附加资产(application.js、application.css 和所有非 JS/CSS 已添加)

./config/environments/production.rb:49: # config.assets.precompile += %w(search.js)

./config/environments/test.rb:10: # 配置静态资产服务器以使用 Cache-Control 进行测试以提高性能

./config/environments/test.rb:11: config.serve_static_assets = true

./Gemfile:30:# Gems 仅用于资产,不是必需的

./Gemfile:32:group :assets 做 ./README.rdoc:159: | |-- 资产

./README.rdoc:192: |-- 资产 ./README.rdoc:199:app/assets

我还尝试在原始 html 中包含资产标签,如<script src="assets/application.js"></script>,但它也不起作用。


我正在开发一个Rails 3.2.13应用程序并遇到以下问题:应用程序/资产文件似乎没有运行!

在我的application.html.erb文件中:

  <%= stylesheet_link_tag    "application" %>
  <%= javascript_include_tag "application" %>

当我运行时rails server,我在日志中看到以下错误消息:

Started GET "/stylesheets/application.css" for 127.0.0.1 at 2013-07-20 15:34:51
-0400

ActionController::RoutingError (No route matches [GET] "/stylesheets/application .css"):
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:21:in ` call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.13)lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call'
railties (3.2.13) lib/rails/engine.rb:479:in `call'
railties (3.2.13) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

Rendered
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/routing_error.erb
 within resc ues/layout (1.0ms)

同时,其他资产(js 文件、css 等)也有错误消息。另一个例子:

Started GET "/javascripts/application.js" for 127.0.0.1 at 2013-07-20
15:34:51 - 0400 ActionController::RoutingError (No route matches [GET] "/javascripts/application .js"): ...

我已经尝试重新启动服务器,重新启动我的计算机,但它没有帮助。我还尝试从其他功能应用程序复制 development.rb 和 production.rb 文件,但也没有效果。

有人可以帮忙吗?


这是我的资产搜索路径,通过运行 Rails.application.config.assets.paths

1/bundler/gems/bootstrap-switc h-rails-2cb6f83ee23e/vendor/assets/stylesheets", "c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/jquery-rails-3.0 .1/vendor/assets/javascripts", "c:/RailsI nstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bootstrap-sass-2.3.2.0/vendor/assets /images", "c :/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bootstrap-sass-2 .3.2.0/vendor/assets/javascripts", "c:/RailsInstaller/Ruby1.9.3/lib/ruby /宝石/1。9.1/gems/bootstrap-sass-2.3.2.0/vendor/assets/stylesheets"] 3/lib/ruby/gems/1.9.1/gems/bootstrap-sass-2 .3.2.0/vendor/assets/javascripts", "c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1. 9.1/gems/bootstrap-sass-2.3.2.0/vendor/assets/stylesheets"] 3/lib/ruby/gems/1.9.1/gems/bootstrap-sass-2 .3.2.0/vendor/assets/javascripts", "c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1. 9.1/gems/bootstrap-sass-2.3.2.0/vendor/assets/stylesheets"]

这对我来说看起来很好......

4

3 回答 3

8

我收到此错误并通过运行解决了它:

RAILS_ENV=生产 rake 资产:预编译

于 2013-10-09T07:16:13.650 回答
1

你在申请 .css 之后有一个空间

于 2014-02-25T00:00:07.990 回答
0

通过创建一个新应用程序并将所有文件移到那里来修复。资产管道现在正常运行。

于 2013-07-25T04:17:56.800 回答