This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Order < ActiveRecord::Base | |
# again it needs to return an array of strings | |
def self.filter_names | |
['ssn', 'credit_card', 'password'] | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'acts_as_csv', git: 'https://github.com/jordangraft/acts_as_csv.git', branch: 'stable-1.0' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Test |
NewerOlder