Montag, 16. Februar 2009

paperclip

paperclip

Installation:

Plugin installieren #script/plugin install git://github.com/thoughtbot/paperclip.git

dann Migration machen
#script/generate migration AddPhotosToEvents

class AddPhotoToEvent <>
def self.up
add_column :events, :photo_file_name, :string
add_column :events, :photo_content_type, :string
add_column :events, :photo_file_size, :integer
end

def self.down
remove_column :events, :photo_file_name
remove_column :events, :photo_content_type
remove_column :events, :photo_file_size
end
end

class Event <>
# Paperclip
has_attached_file :photo

Home:
http://www.thoughtbot.com/projects/paperclip

Gutes Tutorial:
http://burm.net/2008/10/07/the-ruby-on-rails-paperclip-plugin-tutorial-easy-image-attachments/