paper clip 使用

rails g paperclip user avatar

这样生成了一个migration file,下面这段是自动生成滴

01class AddAttachmentAvatarToUser< ActiveRecord::Migration
02  def self.up
03    add_column :users, :avatar_file_name, :string
04    add_column :users, :avatar_content_type, :string
05    add_column :users, :avatar_file_size, :integer
06    add_column :users, :avatar_updated_at, :datetime
07  end
08 
09  def self.down
10    remove_column :users, :avatar_file_name
11    remove_column :users, :avatar_content_type
12    remove_column :users, :avatar_file_size
13    remove_column :users, :avatar_updated_at
14  end
15end
原文地址:https://www.cnblogs.com/lexus/p/1867647.html