For the most part I'm working my through creating AR associations with a legacy DB using the various options AR provides to identify tables and fields.
My current snag is a little outside of that stuff. I have a Company--with an account_manager attribute which is the ID of a User. So.. class Company belongs_to :account_manager, :class_name =>'User', :foreign_key => "account_manager" The User table has an autoinc ID, so that part works out. This works fine for pulling the account_manager's name in a Company.find But... when trying to save a new Company record, I get the following error. User(#blabla) expected, got String(#blabla) OK. Expected what? And since I am saving a Company model, why is User complaining? account_manager is allowed to be NULL, and no data is being assigned to the attribute prior to the save. If I comment out the Company#belongs_to to eliminate the association, then the save works fine. I added class User has_many :companies, :class_name => 'Company', :foreign_key => 'account_manager' to reciprocate the association, but that makes no difference. Googled, read my books, rails guides, but I'm stymied. All suggestions appreciated. Thx. -- gw -- Posted via http://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.

