Bootstrap for Rails dropdown box not working

191 Views Asked by At

I am currently reading Michael Hartl's Ruby on Rails Tutorial. I am in Chapter 8 where we implement sign in and sign out functionality. I am running into a bug in the sections where we create the "Account" dropdown box. All of my tests pass and I have followed the code in the book verbatim but when I hover over or click on the "Account" dropdown box nothing happens.

Here is my _header.erb file:

<header class="navbar navbar-fixed-top">
 <div class="navbar-inner">
  <div class="container">
   <%= link_to "sample app", root_path, id: "logo" %>
   <nav>
    <ul class="nav pull-right">
     <li><%= link_to "Home", root_path %></li>
     <li><%= link_to "Help", help_path %></li>
     <% if signed_in? %>
      <li><%= link_to "Users", '#' %></li>
      <li id="fat-menu" class="dropdown">
       <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        Account <b class="caret"></b>
       </a>
       <ul class="dropdown-menu">
        <li><%= link_to "Profile", current_user %></li>
        <li><%= link_to "Settings", '#' %></li>
        <li class="divider"></li>
        <li>
         <%= link_to "Sign out", signout_path, method: "delete" %>
        </li>
       </ul>
      </li>
     <% else %>
      <li><%= link_to "Sign in", signin_path %></li>
     <% end %>
    </ul>
   </nav>
  </div>
 </div>
</header>

And here is my application.js

//= require jquery
//= require bootstrap
//= require jquery_ujs
//= require_tree .

And my Gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.3'
gem 'bootstrap-sass', '2.0.0'
gem 'bcrypt-ruby', '3.0.1'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

group :development, :test do
 gem 'sqlite3', '1.3.5'
 gem 'rspec-rails', '2.10.0'
 gem 'annotate', '~> 2.4.1.beta'
 gem 'guard-rspec', '0.5.5'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.4'
  gem 'coffee-rails', '3.2.2'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '2.0.0'
end

gem 'jquery-rails'

group :test do
 #gem 'rspec-rails', '2.10.0'
 gem 'capybara', '1.1.2'
 gem 'rb-fchange', '0.0.5'
 gem 'rb-notifu', '0.0.4'
 gem 'win32console', '1.3.0'
 gem 'guard-spork', '0.3.2'
 gem 'spork', '0.9.0'
 gem 'factory_girl_rails', '1.4.0'
end

group :production do
 gem 'pg', '0.12.2'
end


# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

I'm fairly new to rails so I'm not quite sure what other information or code would be best to provide.

Any ideas or suggestions on how to proceed will be much appreciated.

1

There are 1 best solutions below

0
On

I think the problem might be solved by removing id="fat-menu" from <li id="fat-menu" class="dropdown">.