class Report < ActiveRecord::Base
validates :name, :internal_identifier, :uniqueness => true
before_create :set_default_template
def set_default_template
self.template =
"
<%= title %>
<% columns.each do |column| %>
<%= column %> |
<% end %>
<% rows.each do |row| %>
<% row.values.each do |value| %>
<%= value %> |
<% end %>
<% end %>
<%= report_download_link(unique_name, :csv, 'Download CSV') %> |
<%= report_download_link(unique_name, :pdf, 'Download PDF') %>"
end
end