twitter-bootstrap ActionController::RoutingError (No route matching [GET] "/members/js/bootstrap.min.js"):(缺少资产文件)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20466428/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ActionController::RoutingError (No route matches [GET] "/members/js/bootstrap.min.js"):(Missing Asset files)
提问by Kuniharu Aramaki
I am using bootstrap2 and set up tabs
我正在使用 bootstrap2 并设置选项卡
<ul class= "nav nav-tabs">
<li class="active"><a href="#menu1" data-toggle="tab">疑問リスト</a></li>
<li class=""><a href="#menu2" data-toggle="tab">フォロー中の投稿</a></li>
<li class=""><a href="#menu3" data-toggle="tab">ユーザーの投稿</a></li>
</ul>
on show.html.erb(members). It works on the local but doesn't work on the remote(heroku).
在 show.html.erb(成员)上。它适用于本地但不适用于远程(heroku)。
And I checked logs,doing heroku logs and got some error messages. I have no idea how to solve this.Could you help me?
我检查了日志,做 heroku 日志并收到了一些错误消息。我不知道如何解决这个问题。你能帮我吗?
☆error messages
☆错误信息
ActionController::RoutingError (No route matches [GET] "/members/js/bootstrap.min.js"):
ActionController::RoutingError (No route matches [GET] "/members/js/bootstrap.min.js"):
☆show.html.erb(members_controller)
☆show.html.erb(members_controller)
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script src="js/bootstrap.min.js"></script>
ActionController::RoutingError (No route matches [GET] "/members/css/bootstrap.min.css"):
ActionController::RoutingError(没有路由匹配 [GET] "/members/css/bootstrap.min.css"):
回答by marzapower
Change the Javascript file import to this:
将 Javascript 文件导入更改为:
<script src="/assets/bootstrap.min.js"></script>
and the CSS link to this:
以及指向此的 CSS 链接:
<link href="/assets/bootstrap.min.css" media="all" rel="stylesheet" />
On the assets handling in Rails >= 3.x
关于 Rails 中的资产处理 >= 3.x
In Rails 3.x and 4.x all the assets must be placed in the app/assetsdirectory. Javascript files will go into the javascriptsfolder, CSS file into the stylesheetsfolder and the images into the imagesfolder. You can also add more folder to differentiate other asset types.
在 Rails 3.x 和 4.x 中,所有资产都必须放在app/assets目录中。Javascript 文件将放入javascripts文件夹,CSS 文件放入stylesheets文件夹,图像放入images文件夹。您还可以添加更多文件夹以区分其他资产类型。
When in production, all assets will be available under the global folder /assetswith no asset type distinction.
在生产中,所有资产都将在全局文件夹下可用/assets,不区分资产类型。
If you have correctly placed the assets, the best way to load them into your pages is using the absolute reference to them. Eg.
如果您正确放置了资源,将它们加载到页面中的最佳方法是使用对它们的绝对引用。例如。
<%= stylesheet_link_tag "/assets/bootstrap.min" %>
<%= javascript_include_tag "/assets/bootstrap.min" %>
回答by WChasik
If you installed according to instructions: https://github.com/twbs/bootstrap-sass#a-ruby-on-railsand use default template: http://getbootstrap.com/getting-started/#templatethen you just need to remove the following lines from template:
如果您按照说明安装:https: //github.com/twbs/bootstrap-sass#a-ruby-on-rails并使用默认模板:http: //getbootstrap.com/getting-started/#template那么您只需需要从模板中删除以下几行:
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap.min.js"></script>

