Skip to content

Instantly share code, notes, and snippets.

@reggieb
Created September 20, 2016 12:01
Show Gist options
  • Save reggieb/49dc4ac59970373a5ffa5789ac5047a2 to your computer and use it in GitHub Desktop.
Save reggieb/49dc4ac59970373a5ffa5789ac5047a2 to your computer and use it in GitHub Desktop.
A module to simplify grabbing the contents from files in rails apps
module ContentsOf
def contents_of(file_path, location: Rails.root)
File.read File.expand_path(file_path, location)
end
end
@reggieb
Copy link
Author

reggieb commented Sep 20, 2016

Include in any location where you need it:

include ContentsOf

data = contents_of 'test/files/test_data.csv'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment