added dates created/modified to crops csv

This commit is contained in:
Skud
2013-09-16 17:04:39 +10:00
parent d014343667
commit 24255411c9
2 changed files with 8 additions and 3 deletions

View File

@@ -14,8 +14,8 @@ class CropsController < ApplicationController
format.json { render :json => @crops }
format.rss { render :layout => false }
format.csv do
@filename = "Growstuff-Crops-#{Time.zone.now.to_s(:number)}"
@crops = Crop.all
@filename = "Growstuff-Crops-#{Time.zone.now.to_s(:number)}.csv"
@crops = Crop.includes(:scientific_names, :plantings, :seeds)
render :csv => @crops
end
end

View File

@@ -19,7 +19,9 @@ csv.headers :id, :system_name,
:planted_from_bare_root_plant,
:planted_from_advanced_plant,
:planted_from_graft,
:planted_from_layering
:planted_from_layering,
:date_added,
:last_modified
@crops.each do |c|
csv.row c do |csv, crop|
@@ -65,5 +67,8 @@ csv.headers :id, :system_name,
csv.cell :planted_from_graft, planted_from['graft']
csv.cell :planted_from_layering, planted_from['layering']
csv.cell :date_added, c.created_at.to_s(:db)
csv.cell :last_modified, c.updated_at.to_s(:db)
end
end