Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ActionController::RoutingError (No route matches [GET] "/members/js/bootstrap.min.js"):(Missing Asset files)

I am using bootstrap2 and set up tabs

  <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).

And I checked logs,doing heroku logs and got some error messages. I have no idea how to solve this.Could you help me?

☆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)

  <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"):

like image 745
Kuniharu Aramaki Avatar asked Dec 09 '13 08:12

Kuniharu Aramaki


1 Answers

Change the Javascript file import to this:

<script src="/assets/bootstrap.min.js"></script>

and the CSS link to this:

<link href="/assets/bootstrap.min.css" media="all" rel="stylesheet" />

On the assets handling in Rails >= 3.x

In Rails 3.x and 4.x all the assets must be placed in the app/assets directory. Javascript files will go into the javascripts folder, CSS file into the stylesheets folder and the images into the images folder. You can also add more folder to differentiate other asset types.

When in production, all assets will be available under the global folder /assets with no asset type distinction.

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" %>
like image 65
marzapower Avatar answered Sep 30 '22 15:09

marzapower