码迷,mamicode.com
首页 > 其他好文 > 详细

rails使用bootstrap

时间:2016-01-31 21:27:45      阅读:269      评论:0      收藏:0      [点我收藏+]

标签:

在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

标签:

原文地址:http://www.cnblogs.com/jecyhw/p/5173850.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!