linking models ruby on rails -
I have 3 models: users, vendors and cars
I want the users to choose A car and it is added to the user's shopping list.
I have something in the car controller like this:
@user = User.find (params [: user]) @ cellar = vendor.fund (paraam [: vendor ]) @ Car = @ user.car.build (param [: car])
but the seller is not added. How can I do this?
BTW I have this:
class car <
in my model for the car:
@ Car.seller = @seller
after making the car, then do not know about @ car.save
build @ cellar, you need to tell the car That he has a vendor, it really only knows that there is a user because you have created a car from the user.
You can also do this:
@car = Car.new @ car.Sellar = @celler@car.user = @user >
Comments
Post a Comment