Displaying 1 result from an estimated 1 matches for "belongs_to_extra".
2006 Mar 13
1
adding custom cache field
...otal
balance for an account.
So, let there be a transactions table with the field ''amount'' for which we want
to keep track of the total. Then in the accounts table, we will need the
field, ''transactions_total''.
And while declaring the models just add the line,
belongs_to_extra :accounts, :total_cache => :amount
This code below is tested with edge rail, and will work for polymorphic
associations also.
Any comments are welcome.
module ActiveRecord
module Associations # :nodoc:
def self.append_features(base)
super
base.extend(ClassMethods)
end...