मैं कुछ महीने पहले इस बारे में एक पोस्ट में लिखा था। मैंने यह भी लिखा है कि आप कक्षा से गुण कैसे जोड़ सकते हैं, उदाहरण के लिए आईडी का उपयोग नहीं करना (मुझे यह पसंद नहीं है) और इसके बजाय टोकन का उपयोग करना।
Read the post here...
मूल बातें:
एक आईडी
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"
के साथ एक पथ हो और, करने के लिए आप कुछ और करने के लिए इसे बदलना चाहते हैं ...
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"
और प्रारंभकर्ता में
Paperclip.interpolates :token do |attachment, style|
attachment.instance.token
end