简体   繁体   English

Rails 3.2.13-没有路线与[GET]“ / js / jquery.fancybox.js”匹配

[英]Rails 3.2.13 - No route matches [GET] “/js/jquery.fancybox.js”

I was assigned with the task of integrating new designs into an old app , the app was built on 3.2.8 and i did an upgrade to 3.2.13 . 我被分配了将新设计集成到旧应用程序中的任务,该应用程序基于3.2.8构建,并且我进行了升级到3.2.13。 What puzzles me is the js part , i have done everything i could by searching on SO and vice versa but no luck .Already looked into this and this one but somehow the js isn't being served .Following are the parts of code that might be useful - 令我百思不解的是JS部分,我所做的一切,我可以通过搜索对SO,反之亦然,但没有运气.Already看着这个这个 ,但不知何故JS没有被服务。继是代码的部分可能有用-

app/views/layouts/application.html.erb : app / views / layouts / application.html.erb:

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
  <%= javascript_include_tag "html5shiv.js" %>
  <%= javascript_include_tag "fancybox.js" %>

app/views/home/index.html.erb 应用程序/视图/家/ index.html.erb

  <script type="text/javascript" src="/javascripts/html5shiv.js"></script>
  <script type="text/javascript" src="/javascripts/fancybox.js"></script>

Error I get: 错误我得到:

  Started GET "/js/jquery.fancybox.js" for 127.0.0.1 at 2014-05-14 17:17:33 +0530

ActionController::RoutingError (No route matches [GET] "/js/jquery.fancybox.js"):

Updated Error - 更新的错误-

Started GET "/assets/html5shiv.js" for 127.0.0.1 at 2014-05-14 17:17:33 +0530
Served asset /html5shiv.js - 304 Not Modified (0ms)
[2014-05-14 17:17:33] WARN  Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true

Any suggestion or pointers are most welcome . 任何建议或指点都是最欢迎的。 More details will be provided on asking .Thanks in advance , hoping to get it solved :) 有关询问的更多信息,请提前谢谢,希望能解决它:)

First of all I'm not sure why you're including your scripts twice but I would recommend against it. 首先,我不确定您为什么要两次包含脚本但我建议您反对它。 Secondly, are you using the asset pipeline? 其次,您是否正在使用资产管道? If you are (and I strongly recommend that you do) simply add the following to your application.js file: 如果您是(并且强烈建议您这样做),只需将以下内容添加到application.js文件中:

//= require html5shiv
//= require fancybox

And the correct files should be included in your concatenated javascript file. 并且正确的文件应包含在串联的javascript文件中。

Also, the error you're receiving doesn't seem to be connected to the code you posted (as you specify no links to assets living under /js ), but I do believe that when you attempt to link to scripts living at /javascripts (as opposed to assets/javascripts ) you might get a routing error like the one you posted. 另外,您收到的错误似乎与您发布的代码无关(因为您没有指定到/js下的资产的链接),但是我确实相信,当您尝试链接到/javascripts脚本时, (而不是assets/javascripts ),您可能会遇到路由错误,就像您发布的一样。

So, remove the references to your scripts and simply add them to your manifest ( application.js ) and you should be fine. 因此,删除对脚本的引用,只需将它们添加到清单( application.js ),就可以了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 metismenu.js文件未在Rails中加载(没有路由与[GET]“ /users/jquery.metisMenu.js”匹配) - metismenu.js file not loading (No route matches [GET] “/users/jquery.metisMenu.js”) in rails 没有路由匹配[GET]“ /js/vendor/jquery.js” - No route matches [GET] “/js/vendor/jquery.js” Ruby on Rails:PDF.JS ActionController :: RoutingError(没有路由与[GET]“ / pdf js / web / viewer.html”匹配): - Ruby on Rails: PDF.JS ActionController::RoutingError (No route matches [GET] “/pdf js/web/viewer.html”): ActionController :: RoutingError(没有路由与[GET]“ / javascripts / application.js”匹配) - ActionController::RoutingError (No route matches [GET] “/javascripts/application.js”) Rails / Angular:没有匹配的路线[GET] - Rails/Angular: No route matches [GET] 如何从另一个Rails项目中调用JavaScript文件? ActionController :: RoutingError(没有路由与[GET]“ / assets / trackmetrics.js”匹配) - How do call a javascript file from another Rails project? ActionController::RoutingError (No route matches [GET] “/assets/trackmetrics.js”) 服务器上的Rails 6收到很多“ ActionController :: RoutingError:没有路由匹配[GET] /31194a065aebf1674b61.worker.js”的请求 - Rails 6 on server getting a lot of “ActionController::RoutingError: No route matches [GET] /31194a065aebf1674b61.worker.js” requests ActionController :: RoutingError(没有路由匹配[GET]“/members/js/bootstrap.min.js&quot;):(Missing资产文件) - ActionController::RoutingError (No route matches [GET] “/members/js/bootstrap.min.js”):(Missing Asset files) Rails link_to仅在从JS渲染时不引发路线匹配错误 - Rails link_to raise no route matches error only when rendering from JS ActionController :: RoutingError(没有路由与[GET] controller_name / fusioncharts.widgets.js匹配 - ActionController::RoutingError (No route matches [GET] controller_name/fusioncharts.widgets.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM