I am relatively new to rails and I cannot figure out what is going on here. I am using the composed_of method in an ActiveRecord class to create two aggregate properties: shipping_address and billing_address. The object properties are getting populated from the form and validation is working - no problem. When I call order.save, though, everything is being saved except the address fields. I am not getting any errors - it is just that none of the address info is saved to the database. I even ran script/console and manually created and saved an order there - same result.
Anyone have any ideas? Below is the Order class. Thanks.
class Order < ActiveRecord::Base belongs_to :payment_type has_many :line_items, :dependent => :delete_all
composed_of :shipping_address, :class_name => 'Address', :mapping => [ %w(street, street), %w(street2, street2), %w(city, city), %w(state, state), %w(zip, zip) ] do |p| Address.new p[:street], p[:street2], p[:city], p[:state], p[:zip] end
composed_of :billing_address, :class_name => 'Address', :mapping => [ %w(billing_street, street), %w(billing_street2, street2), %w(billing_city, city), %w(billing_state, state), %w(billing_zip, zip) ] do |p| Address.new p[:street], p[:street2], p[:city], p[:state], p[:zip] end
...
end