search for: tax_rat

Displaying 2 results from an estimated 2 matches for "tax_rat".

Did you mean: tax_rate
2006 Aug 13
4
has_many and foreign_key question
...veRecord::Migration def self.up create_table :properties do |t| t.column :address, :string t.column :jurisdiction_id, :string end end class CreateJurisdictionRates def self.up create_table :jurisdiction_rates do |t| t.column :jurisdiction_id, :string t.column :tax_rate, :string t.column :type, :string end end Rails of course sets up auto incrementing ''id'' columns on both tables. Now there are many properties in the same tax jurisdiction that will have the same rates applied to them, so all properties in ''jurisidiction_id'...
2006 Jul 02
0
Rails Core Weekly June 19 - July 2 2006
...dy it nevertheless to sharpen your Ruby-mind. Also, DHH adds Enumerable#sum for calculating a sum from the elements (incidently shadowing AssociationCollection#sum but that is fixed quickly enough). Also Jeremy makes it a bit better by making it block-less Example: payments.sum { |p| p.price * p.tax_rate } payments.sum(&:price) or simply block-less: [1,2,3].sum # => 6 DHH explains this is instead of payments.inject(0) { |sum, p| sum + p.price } In fact the implementation of #sum is virtually the same: inject(0) { |sum, element| sum + yield(element) } Quickly thereafter Nick Seckar ad...