美文网首页
常用GEM的基本使用无标题文章

常用GEM的基本使用无标题文章

作者: eima | 来源:发表于2016-07-15 16:31 被阅读20次

bootstrap-sass

  1. 添加gem并且bundle install
## 务必确保顺序关系
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.6'
gem 'sass-rails', '>= 3.2'  
  1. 导入bootstrap样式表(app/assets/stylesheets/application.scss)
@import "bootstrap-sprockets";
@import "bootstrap";
  1. 修改app/assets/stylesheets/application.scss
去掉 `= require_self 、= require_tree`  使用`@import`
  1. 引入JavaScript文件
//  app/assets/javascripts/application.js
//= require jquery
//= require bootstrap-sprockets

CarrierWave

用来上传文件的gem

安装
gem 'carrierwave'
$ bundle install
基本使用(以上传头像为例)
  1. 生成uploader
rails generate uploader Avatar  ## 产生了app/uploaders/avatar_uploader.rb
  1. 为user表添加avatar字段
rails g migration add_avatar_to_user avatar:string
  1. 挂载uploader
class User < ActiveRecord::Base
   mount_uploader :avatar, AvatarUploader
 end

相关文章

  • 常用GEM的基本使用无标题文章

    bootstrap-sass 添加gem并且bundle install 导入bootstrap样式表(app/a...

  • 无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章 无标题文章无标题文章无标题文章无...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • fasfsdfdf

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标...

  • 无标题文章

    无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章无标题文章

网友评论

      本文标题:常用GEM的基本使用无标题文章

      本文链接:https://www.haomeiwen.com/subject/acvyjttx.html