Created
October 16, 2012 04:02
-
-
Save gamov/3897180 to your computer and use it in GitHub Desktop.
encapsulation?
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
has_many :own_use_contents, :dependent => :destroy, :inverse_of => :own_use_package do | |
def total_quantity | |
loaded? ? to_a.sum(&:quantity) : sum(:quantity) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment