Friday Night Thoughts

enum :role = [:customer, :vendor, :admin]
current_user.costomer? || current_user.vendor? 
User: 
has_many :products, foreign_key: :vendor_id
has_one :cart
has_many :order_products, through: :cart, source: :products
Product:
has_many :cart_products
has_many :carts, through: :cart_products
has_many :users, through: :carts
Cart:
belongs_to :user
has_many :cart_products
has_many :products, through: :cart_products
Cart_Product:
belongs_to :cart
belongs_to :product
has_one :user, through: :cart
f = User.first
f.cart.cart_products
and usingx.errors.full_messages

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store