Skip to content

Instantly share code, notes, and snippets.

@zachinglis
Created March 23, 2009 21:41
Show Gist options
  • Save zachinglis/83798 to your computer and use it in GitHub Desktop.
Save zachinglis/83798 to your computer and use it in GitHub Desktop.
## code
def listing_file=(file)
# self.listing_files.build.attachment = file
self.listing_files.create :attachment => file
self.listing_files.build(:attachment => file)
raise "
#{file}
----
#{self.listing_files.first.attachment}
#{self.listing_files.last.attachment = file}
#{self.listing_files.last.attachment}
"
end
## output
attachment#<File:0x37f4178>
----
/attachments/original/missing.png
attachment#<File:0x37f4178>
/attachments/original/missing.png
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment