Rails 3.2.13:路由错误(没有路由匹配 [GET] “/stylesheets/application.css") [英] Rails 3.2.13: Routing Error (No route matches [GET] "/stylesheets/application.css")
问题描述
更新
这是我的应用中资产"的搜索结果(不包括日志).
Here are the search results for 'asset' in my app (excluding log).
./app/assets/javascripts/application.js:4://任何 JavaScript/Coffee这个目录中的文件,lib/assets/javascripts,供应商/资产/javascripts,
./app/assets/javascripts/application.js:4:// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
./app/assets/javascripts/application.js:5://或插件的供应商/资产/javascripts,如果有的话,可以在这里引用使用相对路径.
./app/assets/javascripts/application.js:5:// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
./app/assets/stylesheets/application.css:5: *此目录中的任何 CSS 和 SCSS 文件,lib/assets/stylesheets,供应商/资产/样式表,
./app/assets/stylesheets/application.css:5: * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
./app/assets/stylesheets/application.css:6:* 或插件的供应商/资产/样式表,如果有的话,可以使用相对路径在此处引用.
./app/assets/stylesheets/application.css:6: * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
./config/application.rb:7: # 如果你在部署到生产之前预编译资产,使用这一行
./config/application.rb:7: # If you precompile assets before deploying to production, use this line
./config/application.rb:8: Bundler.require(*Rails.groups(:assets =>%w(开发测试)))
./config/application.rb:8: Bundler.require(*Rails.groups(:assets => %w(development test)))
./config/application.rb:9: # 如果你想要你的在生产中懒惰编译的资产,使用这一行
./config/application.rb:9: # If you want your assets lazily compiled in production, use this line
./config/application.rb:10: # Bundler.require(:default, :assets,Rails.env)
./config/application.rb:10: # Bundler.require(:default, :assets, Rails.env)
./config/application.rb:54: # 启用资产管道
./config/application.rb:54: # Enable the asset pipeline
./config/application.rb:55: config.assets.enabled = true
./config/application.rb:55: config.assets.enabled = true
./config/application.rb:57: # 你的资产版本,改变这个如果您想使您的所有资产到期
./config/application.rb:57: # Version of your assets, change this if you want to expire all your assets
./config/application.rb:58: config.assets.version = '1.0'
./config/application.rb:58: config.assets.version = '1.0'
./config/environments/development.rb:9:config.assets.enabled = false
./config/environments/development.rb:9: config.assets.enabled = false
./config/environments/development.rb:34: # 不要压缩资源
./config/environments/development.rb:34: # Do not compress assets
./config/environments/development.rb:35: config.assets.compress = false./config/environments/development.rb:37: # 扩展行加载资产
./config/environments/development.rb:35: config.assets.compress = false ./config/environments/development.rb:37: # Expands the lines which load the assets
./config/environments/development.rb:38:config.assets.debug = true
./config/environments/development.rb:38: config.assets.debug = true
./config/environments/production.rb:11: #禁用 Rails 的静态资产服务器(Apache 或 nginx 已经可以了这个)
./config/environments/production.rb:11: # Disable Rails's static asset server (Apache or nginx will already do this)
./config/environments/production.rb:12:config.serve_static_assets = true
./config/environments/production.rb:12: config.serve_static_assets = true
./config/environments/production.rb:15: config.assets.compress = true
./config/environments/production.rb:15: config.assets.compress = true
./config/environments/production.rb:17: # 不要回退到资产如果缺少预编译资产的管道
./config/environments/production.rb:17: # Don't fallback to assets pipeline if a precompiled asset is missed
./config/environments/production.rb:18: config.assets.compile = true
./config/environments/production.rb:18: config.assets.compile = true
./config/environments/production.rb:20: # 为资产生成摘要网址
./config/environments/production.rb:20: # Generate digests for assets URLs
./config/environments/production.rb:21: config.assets.digest =真的
./config/environments/production.rb:21: config.assets.digest = true
./config/environments/production.rb:23: # 默认为Rails.root.join("public/assets")
./config/environments/production.rb:23: # Defaults to Rails.root.join("public/assets")
./config/environments/production.rb:24: # config.assets.manifest =你的路径
./config/environments/production.rb:24: # config.assets.manifest = YOUR_PATH
./config/environments/production.rb:45: # 启用服务来自资产服务器的图像、样式表和 JavaScript
./config/environments/production.rb:45: # Enable serving of images, stylesheets, and JavaScripts from an asset server
./config/environments/production.rb:46: #config.action_controller.asset_host = "http://assets.example.com"
./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:48: # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
./config/environments/production.rb:49: #config.assets.precompile += %w(search.js)
./config/environments/production.rb:49: # config.assets.precompile += %w( search.js )
./config/environments/test.rb:10: # 配置静态资产服务器使用 Cache-Control 测试性能
./config/environments/test.rb:10: # Configure static asset server for tests with Cache-Control for performance
./config/environments/test.rb:11: config.serve_static_assets = true
./config/environments/test.rb:11: config.serve_static_assets = true
./Gemfile:30:# Gems 仅用于资产,不需要
./Gemfile:30:# Gems used only for assets and not required
./Gemfile:32:group :assets do ./README.rdoc:159: ||-- 资产
./Gemfile:32:group :assets do ./README.rdoc:159: | |-- assets
./README.rdoc:192: |-- assets ./README.rdoc:199:app/assets
./README.rdoc:192: |-- assets ./README.rdoc:199:app/assets
我也尝试在原始 html 中包含资产标签,如 <script src="assets/application.js"></script>
,但它也不起作用.
I also tried including the asset tags in raw html, as in <script src="assets/application.js"></script>
, but it didn't work either.
我正在开发一个 Rails 3.2.13
应用程序,但遇到了以下问题:应用程序/资产文件似乎无法运行!
I'm working on a Rails 3.2.13
app and have encountered the following problem:
the app/assets files don't seem to get run!
在我的 application.html.erb 文件中:
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
当我运行 rails server
时,我在日志中看到以下错误消息:
When I run rails server
, I see the following error message in the log:
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 等)也有错误消息.另一个例子:
At the same time, there are error messages for the other assets as well (js files, css etc). Another example:
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 文件,但也没有效果.
I've tried restarting the server, restarting my computer, but it doesn't help. I have also attempted copying development.rb and production.rb files from other functional apps, but no effect either.
有人可以帮忙吗?
这是我的资产搜索路径,通过运行Rails.application.config.assets.paths
:
Here are my assets search path, by running Rails.application.config.assets.paths
:
["c:/Users/user/rails_projects/fyff/app/assets/images","c:/Users/user/rails_projects/fyff/app/assets/javascripts","c:/Users/user/rails_projects/fyff/app/as set/stylesheets","c:/Users/user/rails_projects/fyff/vendor/assets/javascripts" ,"c:/Users/user/rails_projects/fyff/vendor/assets/stylesheets","c:/Rails 安装ler/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts","c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bundler/gems/best_in_place-1152e2256afd/lib/assets/javascripts","c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bundler/gems/bootstrap-switch-rails-2cb6f83ee23e/vendor/assets/javascripts","c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bundler/gems/bootstrap-switch-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:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bootstrap-sass-2.3.2.0/vendor/assets/图片","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/gems/1.9.1/gems/bootstrap-sass-2.3.2.0/vendor/assets/stylesheets"]
["c:/Users/user/rails_projects/fyff/app/assets/images", "c:/Users/user/rails_ projects/fyff/app/assets/javascripts", "c:/Users/user/rails_projects/fyff/app/as sets/stylesheets", "c:/Users/user/rails_projects/fyff/vendor/assets/javascripts" , "c:/Users/user/rails_projects/fyff/vendor/assets/stylesheets", "c:/RailsInstal ler/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts ", "c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bundler/gems/best_in_place-1 152e2256afd/lib/assets/javascripts", "c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/ 1.9.1/bundler/gems/bootstrap-switch-rails-2cb6f83ee23e/vendor/assets/javascripts ", "c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/bundler/gems/bootstrap-switc h-rails-2cb6f83ee23e/vendor/assets/stylesheets", "c:/RailsInstaller/Ruby1.9.3/li b/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/gems/1. 9.1/gems/bootstrap-sass-2.3.2.0/vendor/assets/stylesheets"]
在我看来还不错...
推荐答案
通过创建新应用程序并将所有文件移动到那里来修复.资产管道现在正常运行.
Fixed by creating a new application and moving all the files there. Asset pipeline now functioning normally.
这篇关于Rails 3.2.13:路由错误(没有路由匹配 [GET] “/stylesheets/application.css")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!