You will need 3 extra parameters on your
has_attached_file
declaration in your model:
has_attached_file :photo,
:storage => :s3,
:s3_credentials => Merb.root / "config" / "s3.yml",
:path => ':attachment/:id/:style.:extension'
validates_attachment_presence :photo
validates_attachment_size :photo, :in => 1..200000
The
config/s3.yml
file stores your S3 credentials and bucket name. This is very handy because you can have different configs and inheritance, just like database.yml:
development: &defaults
access_key_id: ...
secret_access_key: ...
bucket: project_images_development
production:
<<: *defaults bucket: project_images_production
That's it!