Module: SimpleCSVUploder
- Defined in:
- lib/SimpleCSVUploder.rb,
lib/SimpleCSVUploder/version.rb
Constant Summary collapse
- VERSION =
'0.1.4'
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
Instance Method Summary collapse
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
4 5 6 |
# File 'lib/SimpleCSVUploder.rb', line 4 def file @file end |
Instance Method Details
#initialize(params = {}) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/SimpleCSVUploder.rb', line 6 def initialize(params = {}) @file = params.delete(:file) super if @file self.filename = sanitize_filename(@file.original_filename) self.content_type = @file.content_type self.file_contents = @file.read end end |
#upload_local ⇒ Object
16 17 18 19 20 |
# File 'lib/SimpleCSVUploder.rb', line 16 def upload_local path = "#{Rails.root}/public/uploads/csv" FileUtils.mkdir_p(path) unless File.exists?(path) FileUtils.copy(@file.tempfile, path) end |