在Gemfile文件中添加'bootstrap-sass',再运行bundle install

gem 'bootstrap-sass'

在config/application.rb添加一行代码,让bootstrap-sass和asset pipeline兼容

  class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de # Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
#让bootstrap-sass和asset pipeline兼容
config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
end

要使用bootstrap还需要在app/assets/stylesheets目录下创建一个css文件:custom.css.scss

内容为:

@import "bootstrap-sprockets"
@import "bootstrap"

另外在app/assets/javascripts/application.js文件中添加一行

//= require bootstrap

这样才能使用bootstrap的javascript的组件。

现在就可以开始使用bootstrap了。

rails使用bootstrap的更多相关文章

  1. 【转】Rails中Bootstrap的安装和使用

     转自:http://blog.csdn.net/lissdy/article/details/9195651   眼看着前端攻城师们都开始使用Bootstrap创作网页,于是也想学着在最近正在学习的 ...

  2. rails引入bootstrap

    1.在Gemfile中增加 gem 'bootstrap-sass', '~> 3.2.0.2'2.bundle install3.把assets/stylesheets/application ...

  3. 【转】Rails 4中使用 Bootstrap 3

    转自:http://rvg.me/2013/11/using-bootstrap-3-with-rails-4/ If you are looking to use Bootstrap 3 with ...

  4. 在Rails中最方便集成使用Bootstrap的方式

    创建项目 rails new BootstrapProject 创建模型 rails g scaffold xxx --skip-stylesheets 运行迁移 rake db:migrate -- ...

  5. rails bug

    variable @fontAwesomeEotPath_iefix is undefined rails generate bootstrap:install如果还有错,保证在加载主提之前impor ...

  6. rails scaffold生成的crud显示自定义的列名

    1. 访问 rails i18n 插件的官方网站 ,查看信息http://guides.rubyonrails.org/i18n.html2. 在Gemfile 中加入  测试rails4.2.1不用 ...

  7. 软件工程资料 - UCSD 怎么教软件工程

    2012年,在上软件工程课的过程中,收集到这个博客,作为学习资料. 原网站 (http://www.arc-trooper.com)已经不存在,这是一个备份. ----------------- 以下 ...

  8. ror笔记2

    在rails app的 config 文件夹中新建unicorn.rb内容如下 worker_processes 2 working_directory "/home/mage/boleht ...

  9. 推荐一个有趣的Chrome扩展程序-查看任意网站的开发技术栈

    对于前端开发人员来说,目前的前端框架层出不穷,最受欢迎的莫过于所谓的前端框架三驾马车:Angular, React和Vue.在学习的过程中,肯定好奇现在的互联网公司的网站用的何种前端框架来开发的. C ...

随机推荐

  1. Luogu P1265修复公路【Prim最小生成树】By cellur925

    题目传送门 政府审批的规则如下: (1)如果两个或以上城市申请修建同一条公路,则让它们共同修建: (2)如果三个或以上的城市申请修建的公路成环.如下图,A申请修建公路AB,B申请修建公路BC,C申请修 ...

  2. 同一台服务器上部署多个Tomcat的配置修改方法

    同一服务器部署多个tomcat时,存在端口号冲突的问题,所以需要修改tomcat配置文件server.xml,以tomcat7为例. 首先了解下tomcat的几个主要端口: <Server po ...

  3. spring 通配符

    原文地址:http://www.bubuko.com/infodetail-848675.html classpath是指 WEB-INF文件夹下的classes目录(惯例大于配置) classpat ...

  4. AtCoder Grand Contest 003 D - Anticube

    题目传送门:https://agc003.contest.atcoder.jp/tasks/agc003_d 题目大意: 给定\(n\)个数\(s_i\),要求从中选出尽可能多的数,满足任意两个数之积 ...

  5. bzoj2301 [HAOI2011]Problem b【莫比乌斯反演 分块】

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=2301 很好的一道题.首先把每个询问转化为4个子询问,最后的结果就是这四个子询问的记过加加减减 ...

  6. Codeforces Round #323 (Div. 2)

    被进爷坑了,第二天的比赛改到了12点 水 A - Asphalting Roads /************************************************ * Author ...

  7. java 反向工具类

    1.ReflectUtil.java package com.example.scansell; import android.util.Log; import java.lang.reflect.C ...

  8. nodejs+multer+ajax文件上传

    前端 html代码 + ajax代码 form表单(无需指定action) <form enctype="multipart/form-data" method=" ...

  9. 修改他人电脑的Windows登录密码

    在别人电脑已登录Windows的情况下: 打开控制面板 -> 管理工具 -> 计算机管理   或者  对Win图标单击右键 -> 计算机管理 -> 本地用户和组 -> 用 ...

  10. CF983A Finite or not?

    思路: 如果p,q不互质,先把q除以p,q的最大公约数.接下来只要b中包含了所有q的质因子就可以了.可以在gcd(q, b) 不等于1的时候不断地用q除以gcd(q, b).最后如果q等于1,说明Fi ...