ruby on rails - Taking cart id and putting into order table -


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 take cart_id , put in column of order table ?

thanks

michael

as said,you should doing way,you having order_id in cart table because associations set that

if want cart_id in order table have change 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 

Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -