• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Relationship Issues

 
village idiot
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1208
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1208
1
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic