On Oct 17, 3:20 pm, "Dave G." <[email protected]> wrote: > I can access transaction.ship_to_address and > transaction.ship_from_address but the query that's generated for both > is: > SELECT `addresses`.* FROM `addresses` WHERE `addresses`.`transaction_id` > = 5 LIMIT 1 > > There's no expected type constraint. > > However, if I do: > Addresses::ShipToAddress.find_by_transaction_id(5) the query is correct > as: > SELECT `addresses`.* FROM `addresses` WHERE `addresses`.`type` IN > ('Addresses::ShipToAddress') AND `addresses`.`transaction_id` = 5 LIMIT > 1 > > I have the workaround but it bugs me that the > transaction.ship_to_address doesn't work correctly. The one thing that > may be wonky is that I'm putting "non-typed" ActiveRecord superclass > entries into addresses but that shouldn't be an issue?
You've told active record that ship_to_address is just a regular address (since you've got class_name => 'Address'), so active record believes you. If ship_to_address should only ever by a Addresses::ShipToAddress then you need to let active record know. Fred > > -- > Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

