Bootstrap Rails 4 sass 布局不起作用 [英] Bootstrap Rails 4 sass layout not working

查看:48
本文介绍了Bootstrap Rails 4 sass 布局不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下内容:

Rails 4.1.0

Rails 4.1.0

ruby 2.1.1p76 (2014-02-24 修订版 45161) [x86_64-linux]

ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-linux]

rvm 1.25.25 (stable) by Wayne E. Seguin,Michal Papis [https://rvm.io/]

rvm 1.25.25 (stable) by Wayne E. Seguin , Michal Papis [https://rvm.io/]

我的 Gemfile:

My Gemfile:

source 'https://rubygems.org'


# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
gem 'bootstrap-sass-extras'


# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer',  platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0',          group: :doc

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring',        group: :development

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

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

# Use debugger
# gem 'debugger', group: [:development, :test]

并且我完成了以下任务以通过我的 railsapp 实现 bootstrap-sass-fluid 布局:

and i have done the following tasks to achieve bootstrap-sass-fluid layout through my railsapp :

捆绑安装

rails g 引导程序:安装

rails g bootstrap:install

rails g bootstrap:布局应用程序流体

rails g bootstrap:layout application fluid

rails g scaffold 帖子标题:字符串描述:文本

rails g scaffold Post title:string description:text

耙数据库:迁移

rails g bootstrap:主题帖子

rails g bootstrap:themed Posts

并且我在我的 rails 应用程序下的assests 文件夹中有这些文件:

and i have these files in my assests folder under my rails app :

/home/pallavsharma/Workspace/testapp/app/assets/stylesheets/application.css

/home/pallavsharma/Workspace/testapp/app/assets/stylesheets/application.css

/home/pallavsharma/Workspace/testapp/app/assets/stylesheets/posts.css.scss

/home/pallavsharma/Workspace/testapp/app/assets/stylesheets/posts.css.scss

/home/pallavsharma/Workspace/testapp/app/assets/stylesheets/scaffolds.css.scss

/home/pallavsharma/Workspace/testapp/app/assets/stylesheets/scaffolds.css.scss

但我的应用程序中仍然没有引导程序布局

but still i dont have my bootstrap layout in my app

我的 application.css 文件内容:

My application.css file contents:

/*

  • 这是一个将被编译成 application.css 的清单文件,这将包括所有文件

  • This is a manifest file that'll be compiled into application.css, which will include all the files

在下面列出.

*

此目录中的任何 CSS 和 SCSS 文件,库/资产/样式表,供应商/资产/样式表,

Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,

或者插件的vendor/assets/stylesheets,如果有的话,可以参考此处使用相对路径.

or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.

*

块引用* 你可以自由地向这个文件添加应用程序范围的样式,它们会出现在底部

Blockquote * 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

在此目录中的其他 CSS/SCSS 文件中定义.这是通常最好创建一个新的

defined in the other CSS/SCSS files in this directory. It is generally better to create a new

每个样式范围的文件.

*

*= require_tree .

*= require_tree .

*= require_self

*= require_self

*/

还有什么需要说的请说.

What else needs to be mentioned please tell.

推荐答案

application.css.scss 应该是:

/*
 *= require bootstrap
 *= require_tree .
 *= require_self
 */

还需要在gemfile中提及这个gem

Also need to mention this gem in gemfile

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

然后

bundle install

它有效.

这篇关于Bootstrap Rails 4 sass 布局不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆