{"action":"created","issue":{"url":"https://api.github.com/repos/ga-dc/pbj-project4/issues/43","labels_url":"https://api.github.com/repos/ga-dc/pbj-project4/issues/43/labels{/name}","comments_url":"https://api.github.com/repos/ga-dc/pbj-project4/issues/43/comments","events_url":"https://api.github.com/repos/ga-dc/pbj-project4/issues/43/events","html_url":"https://github.com/ga-dc/pbj-project4/issues/43","id":107023324,"number":43,"title":"error seeding db with user_id","user":{"login":"christinelovett","id":12041606,"avatar_url":"https://avatars.githubusercontent.com/u/12041606?v=3","gravatar_id":"","url":"https://api.github.com/users/christinelovett","html_url":"https://github.com/christinelovett","followers_url":"https://api.github.com/users/christinelovett/followers","following_url":"https://api.github.com/users/christinelovett/following{/other_user}","gists_url":"https://api.github.com/users/christinelovett/gists{/gist_id}","starred_url":"https://api.github.com/users/christinelovett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christinelovett/subscriptions","organizations_url":"https://api.github.com/users/christinelovett/orgs","repos_url":"https://api.github.com/users/christinelovett/repos","events_url":"https://api.github.com/users/christinelovett/events{/privacy}","received_events_url":"https://api.github.com/users/christinelovett/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-09-17T16:31:49Z","updated_at":"2015-09-17T16:51:04Z","closed_at":null,"body":"I'm trying to get my seed data functional but am having issues connecting a user_id to a separate model, 'ride'. \r\n\r\nI've run a separate migration adding Ride to User and am able to successfully seed the user info. When I try to seed the 'ride' info with manual user_id added to the objects, I get the following error:\r\nPG::ForeignKeyViolation: ERROR:  insert or update on table \"rides\" violates foreign key constraint \"fk_rails_922df144cd\"\r\nDETAIL:  Key (user_id)=(1) is not present in table \"users\".\r\n\r\nthis is an example of what I'm trying to seed:\r\nrides = Ride.create([{user_id: 1, title: 'Rock creek ride'}\r\n\r\nThis is a screenshot of what my schema looks like. I've also tried to check out my DB on psql and the only table I see is current user, with no other info. Not sure what that's about. \r\n\r\n![screen shot 2015-09-17 at 12 30 47 pm](https://cloud.githubusercontent.com/assets/12041606/9939382/f3168d24-5d37-11e5-9fd9-2f780ea37f10.png)\r\n"},"comment":{"url":"https://api.github.com/repos/ga-dc/pbj-project4/issues/comments/141146024","html_url":"https://github.com/ga-dc/pbj-project4/issues/43#issuecomment-141146024","issue_url":"https://api.github.com/repos/ga-dc/pbj-project4/issues/43","id":141146024,"user":{"login":"alexbannon","id":12821988,"avatar_url":"https://avatars.githubusercontent.com/u/12821988?v=3","gravatar_id":"","url":"https://api.github.com/users/alexbannon","html_url":"https://github.com/alexbannon","followers_url":"https://api.github.com/users/alexbannon/followers","following_url":"https://api.github.com/users/alexbannon/following{/other_user}","gists_url":"https://api.github.com/users/alexbannon/gists{/gist_id}","starred_url":"https://api.github.com/users/alexbannon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexbannon/subscriptions","organizations_url":"https://api.github.com/users/alexbannon/orgs","repos_url":"https://api.github.com/users/alexbannon/repos","events_url":"https://api.github.com/users/alexbannon/events{/privacy}","received_events_url":"https://api.github.com/users/alexbannon/received_events","type":"User","site_admin":false},"created_at":"2015-09-17T16:51:04Z","updated_at":"2015-09-17T16:51:04Z","body":"I can't speak to why psql doesn't reflect your schema - that's definitely a problem - but the error sounds like it's trying to create a Ride, you're feeding it a user_id that doesn't exist. Can you show your seed file? My guess is while it's creating the user, it moves onto creating the ride, and because the user isn't in there yet it throws an error.\r\n\r\nI fixed that with a .done(function() after creating the parent seed. It can also be done by adding variables to your users and then doing something like...\r\n\r\nvariable = User.create({blah})\r\nvariable.rides.create({})\r\n\r\nBut I'm not positive on the syntax."}}