napisałem posta o tym kilka miesięcy temu. Pisałem również o tym, jak można dodawać właściwości z klasy, na przykład nie używając identyfikatora (nie podoba mi się to) i zamiast tego używać tokena.
Read the post here...
Podstawy:
aby uzyskać ścieżkę z identyfikatorem
has_attached_file :avatar,
:styles =>
{
:tiny => "48x48>",
:preview => "175x175>",
:large => "300x300>",
:huge => "500x500>"
},
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":class/:attachment/:id/:style.:extension",
:bucket => 'lopsum',
:default_url => "/images/photo01.jpg"
, a jeśli chcesz go zmienić na coś innego ...
has_attached_file :avatar,
:styles =>
{
:tiny => "48x48>",
:preview => "175x175>",
:large => "300x300>",
:huge => "500x500>"
},
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":class/:attachment/:token/:style.:extension",
:bucket => 'lopsum',
:default_url => "/images/photo01.jpg"
oraz w inicjalizatorze
Paperclip.interpolates :token do |attachment, style|
attachment.instance.token
end