有在寶石該發電機包括:
軌道2:
導軌3:
rails generate paperclip Class attachment1 (attachment2 ...)
例如
rails generate paperclip User avatar
產生:
class AddAttachmentsAvatarToUser < ActiveRecord::Migration
def self.up
add_column :users, :avatar_file_name, :string
add_column :users, :avatar_content_type, :string
add_column :users, :avatar_file_size, :integer
add_column :users, :avatar_updated_at, :datetime
end
def self.down
remove_column :users, :avatar_file_name
remove_column :users, :avatar_content_type
remove_column :users, :avatar_file_size
remove_column :users, :avatar_updated_at
end
end
也看到readme
class AddAvatarColumnsToUser < ActiveRecord::Migration
def self.up
change_table :users do |t|
t.has_attached_file :avatar
end
end
def self.down
drop_attached_file :users, :avatar
end
end
由於本例中使用的輔助方法,我應該已經有點更加清楚,我主要的意思遷移涉及現有的回形針列和做重命名和路徑更改將需要文件系統更改等 –
啊,檢查出這個問題,然後:http://stackoverflow.com/questions/270811 5/paperclip-renaming-files-after-theyre-saved/6335337#6335337 – Jared
好吧,這個鎖定或多或少像我在幫手中所做的那樣。那麼猜猜人們是如何做到這一點的。 –