1

trying to learn rails (and I'm still really early on in my development) but I've hit a wall and I'm scratching my head.

I'm trying to leverage bootstrap via bootstrap-sass, and it seems like when I use the default bootstrap navigation bar I can get the bar to render - but it's not interactive. It looks like javascript isn't working properly, but I'm not sure why.

My gemfile:

source 'https://rubygems.org'

gem 'rails'
gem 'bootstrap-sass'
gem 'sprockets'
gem 'sass-rails'
gem 'uglifier'
gem 'coffee-rails'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder'

gem 'sdoc', '~> 0.4.0',          group: :doc


group :development do
  gem 'sqlite3'
  gem 'spring'
end

group :production do
  gem 'pg'
  gem 'rails_12factor'
end

application.css

  *= require_tree .
  *= require_self

app/javascripts/application.js

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

custom.css.scss

@import "bootstrap-sprockets";
@import "bootstrap";

config/application.rb

module FamilyLunch
   class Application < Rails::Application
     config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
end

application.html.erb

<html>
<head>
  <title>Family Lunch | <%= yield(:title) %> </title>
  <%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true %>
  <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
  <%= csrf_meta_tags %>
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<%= render 'layouts/header' %>
<div class='container'>
    <% flash.each do |key, value| %> 
    <div class="alert alert-<%= key %>"><%= value %></div>
    <% end %> 
<%= yield %>
<%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %>
</div>

</body>
</html>
2
  • Add //= require bootstrap-sprockets to application.js. Commented Dec 29, 2014 at 22:10
  • Ahh perfect. Oversight on my part. Commented Dec 29, 2014 at 22:13

2 Answers 2

3

For the JavaScript you have to add //= require bootstrap-sprockets to application.js like this :

app/javascripts/application.js

//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .
Sign up to request clarification or add additional context in comments.

Comments

0

For Solidus create an app/assets/spree/frontend/all.js and include:

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

this will override the app/assets/application.js

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.