Skip to content

Instantly share code, notes, and snippets.

@gamov
Created October 16, 2012 04:02
Show Gist options
  • Save gamov/3897180 to your computer and use it in GitHub Desktop.
Save gamov/3897180 to your computer and use it in GitHub Desktop.
encapsulation?
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