aspose file tools*
The moose likes Ruby and the fly likes Relationship Issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Ruby
Bookmark "Relationship Issues" Watch "Relationship Issues" New topic
Author

Relationship Issues

Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1195
I've got two tables, Users and Statuses. I want the user_id index from Statuses to be the id from Users. Right now, I can create a new user from a form and all records are created correctly. When I try to create a new status for that user in the new status form, by putting the id number in the user_id field, and some inane comment in the content field, only the id and content records are created for Status, and user_id is nil. I can't figure out why! Here are the rb files for each:







Can somebody tell me what I've done wrong? I've been staring at this for so long it is starting to make no sense.
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1195
Okay, I figured out a way to update Status from the console. When I use update_attribute to set the user_id property in Status, the web pages function properly. When I created another user and made another status for them again the user_id property was nil. I can fix it from the console, but I need to figure out what is going on here. My problem then, is why is user_id not being assigned the value of id from the User table. There must be something wrong with the way Statuses are being put into the database if the associations work once the missing property is set. Where should I begin to troubleshoot?
Carol Murphy
village idiot
Bartender

Joined: Mar 15, 2001
Posts: 1195
I found the problem. When Status was first migrated, it had a name property that was later changed to user_id. I forgot to update the controller to reflect that change in the permitted parameters. Now it works! See, I knew posting here was a good idea!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Relationship Issues