简体   繁体   中英

can't install bootstrap on ruby on rails

I'm a beginer in Ruby on rails and i tried to install Bootstrap but always it failed

Here is how i proceded to install it .

1)

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.0.6'
# 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'
gem 'bootstrap', '~> 4.0.0.beta2.1'
gem 'sprockets-rails', '~> 3.2', '>= 3.2.1'
# 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', '>= 3.3.0'
end

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

2)

 @import "bootstrap";

3) In the file application.js i paste this :

//= require jquery3
//= require popper  
//= require bootstrap-sprockets  
//= require turbolinks  
//= require_tree .

4) I got an error in the application.html.erb file so i changed "application" in the two lines to "application.scss" and "application.js" and then i installed Node.js

    <!DOCTYPE html>
<html>
  <head>
    <title>Bali</title>
    <%= csrf_meta_tags %>

    <%= stylesheet_link_tag    'application.scss', media: 'all', 'data-turbolinks-track': 'reload' %>
    <%= javascript_include_tag 'application.js', 'data-turbolinks-track': 'reload' %>
  </head>

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

I did Bundle Install and reset the server. Then nothing happen to the homepage, the font didn't change...

Thank for your help

Ok now i have this, it seem that bootstrap is not displayed totaly

Bootstrap has been installed successfully you however need to create an HTML page to leverage that new CSS you have.

Run this in your terminal to make your own custom page.

rails generate controller home index

You can now update the app/views/home/index.html.erb file to contain whatever Bootstrap styled HTML you want.

The last step in order for you to view your page would be to modify the routes.rb file. In that file, add the line root 'home#index' to see your new page when you visit your Rails app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM