Skip to content

Instantly share code, notes, and snippets.

@walidvb
Created April 23, 2014 23:10
Show Gist options
  • Select an option

  • Save walidvb/11235711 to your computer and use it in GitHub Desktop.

Select an option

Save walidvb/11235711 to your computer and use it in GitHub Desktop.
class Chapter < ActiveRecord::Base
has_attached_file :file,
:storage => :filesystem
def to_file
if Rails.env != "test"
#open(file.url) { |f| @content = f.read}
@content = file.copy_to_local_file.read
@filename = file_file_name
else
@content = "Test content"
@filename = "Filename"
end
result = {
:filename => @filename,
:content => @content
}
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment