无法在rails上的ruby上安装bootstrap

时间:2017-12-05 14:33:02

标签: ruby-on-rails ruby

我是Ruby on rails的初学者,我试图安装 Bootstrap ,但总是失败

以下是我如何安装它。

1)

from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from app import create_app
from app import models
from app.models import db

app = create_app('dev')
migrate = Migrate(app, db)
manager = Manager(app)

manager.add_command('db', MigrateCommand)

if __name__ == '__main__':
    manager.run()

2)

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]

3) application.js 文件中,我粘贴了这个:

 @import "bootstrap";

4)我在application.html.erb文件中出错,所以我将两行中的“application”更改为“application.scss”和“application.js”,然后我安装了Node.js

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

我做了Bundle Install并重置了服务器。然后主页上没有任何变化,字体没有改变......

感谢您的帮助

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

1 个答案:

答案 0 :(得分:0)

Bootstrap已成功安装,但您需要创建一个HTML页面来利用您拥有的新CSS。

在您的终端中运行此操作以制作您自己的自定义页面。

rails generate controller home index

您现在可以更新app/views/home/index.html.erb文件以包含您想要的任何Bootstrap样式的HTML。

为了查看您的页面,最后一步是修改routes.rb文件。 在该文件中,添加行root 'home#index'以在您访问Rails应用时查看新页面。