Method: DynamicContent#parse_csv
- Defined in:
- app/controllers/concerns/dynamic_content.rb
#parse_csv(mapper) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/concerns/dynamic_content.rb', line 14 def parse_csv(mapper) csv_path = "#{Rails.root}/lib/mappers/#{mapper}.csv" csv_dir = "#{Rails.root}/lib/mappers" Dir.mkdir(csv_dir) unless File.exists?(csv_dir) if (!File.exist?(csv_path)) File.open(csv_path, "w+") do |f| f.write("id,route,title,redirect_to,thumbnail\n") end end CSV.parse(File.read(csv_path), :headers => true, :header_converters => :symbol) end |