Skip to content

Instantly share code, notes, and snippets.

View jordangraft's full-sized avatar

Jordan Graft jordangraft

View GitHub Profile
class Order < ActiveRecord::Base
# again it needs to return an array of strings
def self.filter_names
['ssn', 'credit_card', 'password']
end
end
class Order < ActiveRecord::Base
# needs to return an array of strings representing method names that exist for the model
def self.optional_csv_attributes
['state']
end
def state
return 'the state'
end
class Order < ActiveRecord::Base
has_many :line_items
def has_many_associations
self.reflect_on_all_associations(:has_many).collect {|assoc| "#{assoc.name}_total_amount"}
end
def line_items_total_amount
line_items.sum(:amount)
gem 'acts_as_csv', git: 'https://github.com/jordangraft/acts_as_csv.git', branch: 'stable-1.0'