bootstrap
gem 'bootstrap-sass'
mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss
@import "bootstrap-sprockets";
@import "bootstrap";
简化form
gem 'simple_form'
rails generate simple_form:install --bootstrap
# simple_form
<%= simple_form_for @group do |f| %>
<div class="form-group">
<%= f.input :title, input_html: { class: "form-control"} %>
<%= f.input :description, input_html: { class: "form-control"} %>
</div>
<%= f.submit "Submit", class: "btn btn-primary", data: { disable_with: "Submiting..." } %>
<% end %>
会员系统
gem 'devise'
rails g devise:install
rails g devise user
rake db:migrate
分页
gem 'will_paginate'
@posts = @group.posts.recent.paginate(:page => params[:page], :per_page => 5)
<%= will_paginate @posts %>
字体图标库
gem 'font-awesome-rails'
上传文件
gem 'carrierwave'
rails g migration add_attachment_to_resume
class AddAttachmentToResume < ActiveRecord::Migration[5.0]
def change
add_column :resumes, :attachment, :string
end
end
rails g uploader attachment
class Resume < ApplicationRecord
belongs_to :user
belongs_to :job
mount_uploader :attachment, AttachmentUploader
validates :content, presence: true
end
<%= simple_form_for [@job, @resume] do |f| %>
<%= f.input :content %>
<%= f.input :attachment %>
<%= f.submit "送出" %>
<% end %>
def resume_params
params.require(:resume).permit(:content, :attachment)
end
上传图片与上面配合
gem "mini_magick"
rails g uploader image
rails g migration add_image_to_product
class Product < ApplicationRecord
+ mount_uploader :image, ImageUploader
end
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
- # include CarrierWave::MiniMagick
+ include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
+ process resize_to_fit: [800, 800]
+ version :thumb do
+ process resize_to_fill: [200,200]
+ end
+ version :medium do
+ process resize_to_fill: [400,400]
+ end
model 注释
gem 'annotate'
排序功能
gem 'acts_as_list'
预览邮件
gem letter_opener
状态机
gem "aasm"
密码管理
gem figaro
七牛云
gem 'carrierwave-qiniu'
gem 'qiniu-rs'
heroku debug
gem 'fog' 云上传图片
gem rucaptcha 验证码
三个小 jQuery 插件应用
Autosize
Countdown
WoW
浏览量
gem 'impressionist'
日历
gem "simple_calendar", "~> 2.0"
api
gem 'rest-client'
js下拉选择
gem "select2-rails"
打开App,阅读手记