Last active
December 11, 2015 17:48
-
-
Save spacecowb0y/4637001 to your computer and use it in GitHub Desktop.
Sexy methods for AR objects.
This file contains 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
def unread_comments | |
readable_comments.delete_if {|c| c.created_at < c.discussion.assignments.find_by_user_id(id).updated_at } | |
end | |
def create_new_invoice! | |
invoice = invoices.build | |
order_item_options.delete_if{ |o| o.price == 0 }.map{ |o| invoice.invoice_lines.build(:order_item_id => o.order_item.id, :description => o.order_item.name, :unit_price => o.price) } | |
invoice.save! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment