I'm trying to assign random user\_id's to products that are generated from the seeds database. Everything is generating for me as I want it except for the user\_id which is rendering nil. I'm trying to get a better understanding of how the belongs\_to interaction works - any help here would be awesome! 

```
10.times do |n|
 name = Faker::Name.name
 job = Faker::Company.name
 User.create!(name: name,
               job: job  )
end

10.times do |n|
 users = User.all
 name = "Turkey"
 price = Random.rand(42-10) + 10
 user_id = users[1..10] 
 Product.create!(name: name,
                 price: price,  
                 user_id: user_id)
end             

```

Thanks in advance for the help! 

Edit \*\* Thanks for the help everyone. This is what I ended up changing the code to. 

```
users = User.order(:created_at).take(6)
10.times do |n|
name = "Turkey"
price = Random.rand(42-10) + 10
users.each { |user| user.products.create!(name: name, price: price)}
end               

```