-
Followers
lrbalt (Assigned To) , mcraven
AttachmentsAssociationsNo associationsActivity
on Apr 24, 2009 @ 12:54PM UTC * By mcraven
Attachment ActionController_Exceptioncaughtcsv_actions.jpg addedfile:bb23EKmoGr3Ox_eJe5aVNr: CVS export failure
on Apr 24, 2009 @ 12:54PM UTC * By mcraven
Attachment ActionController_Exceptioncaughtxml_export.jpg addedfile:bchQN8moGr3Ox_eJe5aVNr: XML export failure
(In revision:a826fb9a11ed9ec7dce36aaf445f8646889f316c) improve data controller and fix #891 where the export of xml did not work because of the removal of tag.user_id
Branch: master
Since I cannot reproduce, could you try the following?
In /path/to/tracks/app/controller/data_controller.rb replace the method csv_actions with this one
<codeblock>
def csv_actions
content_type = 'text/csv'
CSV::Writer.generate(result = "") do |csv|
csv << ["id", "Context", "Project", "Description", "Notes", "Tags",
"Created at", "Due", "Completed at", "User ID", "Show from",
"state"]
current_user.todos.find(:all, :include => [:context, :project]).each do |todo|- Format dates in ISO format for easy sorting in spreadsheet Print
- context and project names for easy viewing
todo.project_id.nil? ? "" : todo.project.name,
todo.description,
todo.notes, todo.tags.collect{|t| t.name}.join(', '),
todo.created_at.to_formatted_s(:db),
todo.due? ? todo.due.to_formatted_s(:db) : "",
todo.completed_at? ? todo.completed_at.to_formatted_s(:db) : "",
todo.user_id,
todo.show_from? ? todo.show_from.to_formatted_s(:db) : "",
todo.state]
end
end
send_data(result, :filename => "todos.csv", :type => content_type)
end
</codeblock>
Here is the original code:def csv_actions content_type = 'text/csv' CSV::Writer.generate(result = "") do |csv| csv << ["id", "Context", "Project", "Description", "Notes", "Tags", "Created at", "Due", "Completed at", "User ID", "Show from", "state"] current_user.todos.find(:all, :include => [:context, :project]).each do |todo| csv << [todo.id, todo.context.name, todo.project_id = todo.project_id.nil? ? "" : todo.project.name, todo.description, todo.notes, todo.tags.collect{|t| t.name}.join(', '), todo.created_at.to_formatted_s(:db), todo.due = todo.due? ? todo.due.to_formatted_s(:db) : "", todo.completed_at = todo.completed_at? ? todo.completed_at.to_formatted_s(:db) : "", todo.user_id, todo.show_from = todo.show_from? ? todo.show_from.to_formatted_s(:db) : "", todo.state] end end send_data(result, :filename => "todos.csv", :type => content_type) end
When I insert the following:def csv_actions content_type = 'text/csv' CSV::Writer.generate(result = "") do |csv| csv << ["id", "Context", "Project", "Description", "Notes", "Tags", "Created at", "Due", "Completed at", "User ID", "Show from", "state"] current_user.todos.find(:all, :include => [:context, :project]).each do |todo| csv << [todo.id, todo.context.name, todo.project_id.nil? ? "" : todo.project.name, todo.description, todo.notes, todo.tags.collect{|t| t.name}.join(’, ’), todo.created_at.to_formatted_s(:db), todo.due? ? todo.due.to_formatted_s(:db) : "", todo.completed_at? ? todo.completed_at.to_formatted_s(:db) : "", todo.user_id, todo.show_from? ? todo.show_from.to_formatted_s(:db) : "", todo.state] end end send_data(result, :filename => "todos.csv", :type => content_type) end
It exits with a syntax error.
Ideas?
Mark C.
(In revision:ceba3679421ed7fac4d018e861878e83dfd23a64) fix #891. Somehow the assignment causes an error for some people.
Don't know why though, but this fix is harmless anyway.
Branch: master
(In revision:a826fb9a11ed9ec7dce36aaf445f8646889f316c) improve data controller and fix #891 where the export of xml did not work because of the removal of tag.user_id
Branch: master
(In revision:ceba3679421ed7fac4d018e861878e83dfd23a64) fix #891. Somehow the assignment causes an error for some people.
Don't know why though, but this fix is harmless anyway.
Branch: masterTime ExpenditureLoading


