簡體   English   中英

無法在導軌上的紅寶石上安裝引導程序

[英]can't install bootstrap on ruby on rails

我是Ruby on Rails的初學者,我嘗試安裝Bootstrap,但始終失敗

這是我進行安裝的方法。

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)在文件application.js中,我將其粘貼:

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

4)我在application.html.erb文件中出現錯誤,因此我將兩行中的“ application”更改為“ application.scss”和“ application.js”,然后安裝了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>

我做了捆綁安裝並重置了服務器。 然后主頁什么都沒有發生,字體沒有改變...

謝謝您幫忙

好的,現在我有了這個,似乎引導程序沒有完全顯示

Bootstrap已成功安裝,但是您需要創建一個HTML頁面來利用您擁有的新CSS。

在您的終端中運行此命令以創建自己的自定義頁面。

rails generate controller home index

現在,您可以更新app/views/home/index.html.erb文件,以包含所需的任何Bootstrap樣式的HTML。

要查看您的頁面的最后一步是修改routes.rb文件。 在該文件中,添加行root 'home#index'以在訪問Rails應用程序時查看新頁面。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM