Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created June 2, 2011 18:47
Show Gist options
  • Save brandon-beacher/1005011 to your computer and use it in GitHub Desktop.
Save brandon-beacher/1005011 to your computer and use it in GitHub Desktop.
add_column :attachments, :file, :string
class Attachment < ActiveRecord::Base
mount_uploader :file, AttachmentUploader
end
attachment = Attachment.first
=> #<Attachment id: 2, created_at: "2011-05-13 22:13:22", updated_at: "2011-05-13 22:13:22", owner_type: "Suit", owner_id: 8, file: "secretsofthejavascriptninja.pdf", original_filename: "SecretsoftheJavaScriptNinja.pdf", content_type: "application/pdf">
> attachment.file
=> /uploads/attachment/file/2/secretsofthejavascriptninja.pdf
> attachment.file.class
=> AttachmentUploader
> attachment.file.filename
=> nil
> attachment.file.file
=> #<CarrierWave::SanitizedFile:0x00000106a7b6b8 @file="/Users/brandon/Sites/highgroove/discovery-port/public/uploads/attachment/file/2/secretsofthejavascriptninja.pdf", @original_filename=nil, @content_type=nil>
> attachment.file.file.class
=> CarrierWave::SanitizedFile
> attachment.file.file.filename
=> "secretsofthejavascriptninja.pdf"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment