我似乎找不到我的代码有什么问题,但是单击时的折叠按钮不会激活下拉菜单。我在我的应用程序的其他区域有 javascript 工作,但导航按钮不起作用。这是我的项目的链接:https ://github.com/parisliahyun/citibikeapp
这是我的代码:
_header.html.erb:
<nav class="navbar navbar-default" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<% if logged_in? %>
<li><%= link_to "Awesome Citi", root_path %> </li>
<li><%= link_to "My Account", account_path %> </li>
<li><%= link_to "New Search", new_search_path %> </li>
<li><%= link_to "Saved Destinations", user_path(current_user) %></li>
<li><a href="http://citibikenyc.com/stations"target="_blank">Station Map</a></li>
<li><%= link_to 'Logout', session_path, :method => :delete %> </li>
<% end %>
</ul>
</div>
</nav>
应用程序.js:
...
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require_tree .
应用程序.html.erb:
<!DOCTYPE html>
<html>
<head>
<title>Awesome Citi</title>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
<meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<%= render 'layouts/header'%>
<div class="container">
<%= yield %>
</div>
<footer>
</footer>
</div>
</body>
</html>
所有帮助表示赞赏。