Skip to content

Instantly share code, notes, and snippets.

@dnch
Created February 12, 2010 05:53
Show Gist options
  • Save dnch/302344 to your computer and use it in GitHub Desktop.
Save dnch/302344 to your computer and use it in GitHub Desktop.
accessing raw paperclip data
def _paperclip_is_csv(field_name)
if attachment_for(field_name).dirty?
begin
FasterCSV.read(attachment_for(field_name).queued_for_write[:original].path)
rescue FasterCSV::MalformedCSVError => e
errors.add_to_base("Please ensure that the #{field_name.to_s.titleize} is a valid CSV file.")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment