Ruby on Rails
Friday, January 19, 2018
Using scaffold, I generated two models, Person and Offer, and the forms to manage them. Offer has a belong_to association with Person. After running the generator, all the forms immediately worked fine.
But then I discovered an external requirement that the foreign key column in the offers table, which was named person_id per Rails conventions, needed to be renamed as worker_id. Since then, the Offer forms don't work. They evoke a variety of errors, all related to the renamed column. It seems that the system no longer recognizes it as implementing the Offer to Person association.
I figure I need to make some declaration somewhere to restore this associative functionality, but I can't figure out how to do this. Can you help?
belongs_to (and other assocns) has options for class name and foreign key. see ri or doc.
otoh, i wonder if it would have been easier to create just another Worker resource (and probly delete Person); but ymmv prolly.
best regards --botp
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAAwHHQjVVtDw-t9JdWcO5e-F%3DYJ0qr53FRjhg2MhbtsXCiNwCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment