Ruby on Rails Sunday, October 31, 2010

1. The polymorphic part isn't necessary. If you just expect to have one
model that has file attachments then it's not going to help you.
However, if you have multiple models that have attachments, then you
might want to go the polymorphic way. See
http://guides.rubyonrails.org/association_basics.html#polymorphic-associations.

2. You're markup should work. On the website, I'm using HAML as a
replacement for ERB. Also, I'm using the 'simple form' gem. So my markup
is going to look different than yours. Plus, I'm using a nested form.

3. The :path is the file path that file will be placed in your S3
account.
In your case, you specified

:styles => { :thumb => "100x100#", :small => "150x150>" }

So when you upload a file, paperclip will generate these two image
styles for you as separate files. If the original file was bigger than
both of these styles, then you'll also have a third 'original' file.

If you have

:path => "/:attachment/:id/:style.:extension"

your S3 file path will be something like '/photo/1/thumb.png'

If you used

:path => "/:style/:id"

your S3 file path would be '/thumb/1'. This won't work because it's not
specific enough. You'll just keep overwriting the same file. ':filename'
is automatically available for you to use because each upload has to
have a filename.

If you're using Firefox, I recommend the 'S3Fox' add-on that will allow
you to browse your S3 account through Firefox.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment