Reputation: 309
i have model order.rb :
class Order < ActiveRecord::Base
has_one :cart
end
and model cart.rb :
class Cart < ActiveRecord::Base
include SecurelyPermalinkable
belongs_to :user
belongs_to :order
end
How can i take cart_id and put it in column of order table ?
Thanks
Michael
Upvotes: 0
Views: 143
Reputation: 33552
As I said,you should be doing like that way,You will be having order_id
in your cart
table because your associations are set like that
if you really want cart_id
in your order
table then you have to change your associations.
Order model
class Order < ActiveRecord::Base
belongs_to :cart
end
Cart model
class Cart < ActiveRecord::Base
include SecurelyPermalinkable
belongs_to :user
has_one :order
end
Upvotes: 1