3

Hello everyone I have installed bootstrap for my application, and it is not working out to well. Here is my application.scss file

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

Here is my application.rb file:

<!DOCTYPE html>
<html>
  <head>
    <title>BootstrapApp</title>

    <%= stylesheet_link_tag    'default', media: 'all', 'data-turbolinks-track' => true%>
    <%= javascript_include_tag 'default', 'data-turbolinks-track' => true %>
    <%= csrf_meta_tags %>
  </head>

  <body>
        <%= yield %>
  </body>
</html>

application.js file:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file. JavaScript code in this file should be added after the last require_* statement.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets 
//= require turbolinks
//= require_tree .

Finally here is my Gem File:

source 'http://rubygems.org'

gem 'bootstrap-sass', '~> 3.3.5'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platform: :mri
end

group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

Here is what I am getting when trying to add a navbar to my webpage:

enter image description here

beastlyCoder
  • 2,349
  • 4
  • 25
  • 52
  • Are you getting any errors? If yes, please post the error message? – Arun Kumar Mohan Dec 06 '16 at 04:07
  • No I am not getting any error messages, it's just that when I go to my index page the text is just normal html with no bootstrap whatsoever with bootstrap added I should be able to see the change in text no? – beastlyCoder Dec 06 '16 at 04:08
  • remove bootstrap-sprockets from application.scss/css. – Milind Dec 06 '16 at 04:09
  • @Aaron Hmm, strange. Did you try any bootstrap-specific styles to confirm? Can you link to a screenshot if possible? As far as I see, I don't find any mistakes. – Arun Kumar Mohan Dec 06 '16 at 04:10
  • @ArunKumar I have added a screenshot of my display. As you can tell bootstrap is not being applied – beastlyCoder Dec 06 '16 at 04:14
  • No it is not, it is ok I will try and work out the issues sense it doesn't seem to be in my code thanks for all the help. I will accept your answer to this post just because you have been very nice. – beastlyCoder Dec 06 '16 at 04:25
  • @ArunKumar I am getting this error: TypeError: Object doesn't support this property or method(this happened when I added your two lines of code replacing my old lines) – beastlyCoder Dec 06 '16 at 04:27
  • Possible duplicate of [Sass::SyntaxError: File to import not found or unreadable: bootstrap-sprockets](http://stackoverflow.com/questions/26135126/sasssyntaxerror-file-to-import-not-found-or-unreadable-bootstrap-sprockets) – vanburen Dec 06 '16 at 06:07

2 Answers2

3

The problem is you're not requiring application.scss and application.js.

<%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track' => true%>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>

If you are getting the Object does not support the property or method error, then use the latest gem for "coffee-script-source" (like 1.10.0) - anything other than version 1.9.x.

Add the following line to Gemfile, run bundle install and restart the server.

gem 'coffee-script-source', '~> 1.11', '>= 1.11.1'
Arun Kumar Mohan
  • 11,517
  • 3
  • 23
  • 44
  • still... after installing this. It gives me the same exact error :( – beastlyCoder Dec 06 '16 at 04:37
  • @Aaron You should try the first answer of [this](http://stackoverflow.com/questions/28312460/object-doesnt-support-this-property-or-method-rails-windows-64bit) question. Its a bit dirty, but should work. – Arun Kumar Mohan Dec 06 '16 at 04:39
0

I finally got this to work. this link provided me with my solution. Thanks to everyone who helped me on this post, it was greatly appreciated and a great learning experience :)

Community
  • 1
  • 1
beastlyCoder
  • 2,349
  • 4
  • 25
  • 52