在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. loj#2540. 「PKUWC2018」随机算法

    传送门 完了pkuwc咋全是dp怕是要爆零了-- 设\(f(S)\)表示\(S\)的排列数,\(S\)为不能再选的点集(也就是选到独立集里的点和与他们相邻的点),\(mx(S)\)表示\(S\)状态下 ...

  2. Luogu P2278 [HNOI2003]操作系统【优先队列/重载运算符/模拟】 By cellur925

    题目传送门 本来是照着二叉堆的题去做的...没想到捡了个模拟...不过模拟我都不会...我好弱啊... 其实核心代码并不长,比辰哥的标程短到不知哪里去...但是思路需要清晰. 读题的时候我明白,当有优 ...

  3. 序列/树上差分小结 By cellur925

    首先我们需要注意一下的是,差分比较适用于修改比较多而查询比较少的情况. 一.序列上差分 借教室  这是一道二分答案,在check函数中用到差分技巧的一道题,譬如说我们要把一个序列中[l,r]区间都加上 ...

  4. docker监控之cadvisor

    docker run -d \ --volume=/:/rootfs:ro \ --volume=/var/run:/var/run:rw \ --volume=/sys:/sys:ro \ --vo ...

  5. SecureCRT的配色方法

    配色后效果如下: 下面开始配色 1.首先配置成默认模式 2.终端(Terminal)==>仿真(Emulation) 按图中标注进行勾选,勾选完毕点击确认 2.选项(Options)==> ...

  6. jQuery在$(function(){})中調用函數

    任務太緊,很少記筆記,記下一篇jQuery中調用函數的例子: 該方法是在載入頁面的時候,判斷 ModelName 不為空,則獲取Model信息加載到Table中: 另外,在點擊半成品編號文本框時,也調 ...

  7. Android获取声音长度

    代码 MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever(); metaRetriever.setDataSource( ...

  8. 安装nginx的一些注意事项

    1.如何彻底屏蔽掉Nginx的banner 为了安全或者某些个人的原因,如果要屏蔽掉nginx的banner,要修改以下几个位置: src/http/ngx_http_header_filter_mo ...

  9. sqlserver2012 offset

    /* * Hibernate, Relational Persistence for Idiomatic Java * * License: GNU Lesser General Public Lic ...

  10. 移动端超级好用的reset.css(只做参考哦具体以你们实际项目需求为准)

    html { color: #333; /*规定主色调,依据业务场景(非必须)*/ background: #F6F6F6; /*规定主背景,依据业务场景(非必须)*/ overflow-y: aut ...