[英]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.