Created
April 23, 2014 23:10
-
-
Save walidvb/11235711 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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