Bootstrap 样式未应用于 Rails 页面
Bootstrap styling not being applied to Rails page
我是 Rails 的新手,所以一直在关注构建项目的在线视频教程。
我一直在尝试添加 Bootstrap,但即使在
之后
- 添加 Gem,
- 进行捆绑安装,
- 正在重新启动 mysql 服务器,并且
- 将 scss @bootsrap 导入添加到 application.css.scss 文件,
它仍然没有拉到我的索引页。
有什么我想念的吗?
这是我的 application.css.scss
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_self
*/
// Custom bootstrap variables must be set or imported before bootstrap itself.
@import "bootstrap-sprockets";
@import "bootstrap";
这是我的 gem 文件:
source 'https://rubygems.org'
gem 'rails', '4.2.6'
gem 'sqlite3'
gem 'simple_form', '>= 3.2.1'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '>= 3.2'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
谢谢!
请加入你的application.html.erb
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
并添加您的 application.css
@import "bootstrap-sprockets";
@import "bootstrap";
@import 'bootstrap/theme';
我是 Rails 的新手,所以一直在关注构建项目的在线视频教程。
我一直在尝试添加 Bootstrap,但即使在
之后- 添加 Gem,
- 进行捆绑安装,
- 正在重新启动 mysql 服务器,并且
- 将 scss @bootsrap 导入添加到 application.css.scss 文件,
它仍然没有拉到我的索引页。
有什么我想念的吗?
这是我的 application.css.scss
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_self
*/
// Custom bootstrap variables must be set or imported before bootstrap itself.
@import "bootstrap-sprockets";
@import "bootstrap";
这是我的 gem 文件:
source 'https://rubygems.org'
gem 'rails', '4.2.6'
gem 'sqlite3'
gem 'simple_form', '>= 3.2.1'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '>= 3.2'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
gem 'byebug'
end
group :development do
gem 'web-console', '~> 2.0'
end
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
谢谢!
请加入你的application.html.erb
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
并添加您的 application.css
@import "bootstrap-sprockets";
@import "bootstrap";
@import 'bootstrap/theme';