Skip to content

Instantly share code, notes, and snippets.

@osdrv
Created February 4, 2012 18:02
Show Gist options
  • Save osdrv/1739235 to your computer and use it in GitHub Desktop.
Save osdrv/1739235 to your computer and use it in GitHub Desktop.
class ContractFile < ActiveRecord::Base
belongs_to :contract
has_attached_file :data,
:url => "/assets/paperclip/:parent_id/:attachment/:id/:style/:filename"
#:url => '/public/system/:attachment/foto_:basename.:extension',
#:url => '/assets/:id/foto_:basename.:extension'
validates_attachment_size :data, :less_than => 5.megabytes
Paperclip.interpolates :parent_id do |a, s|
a.instance.contract.id.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment