I have three Models
Bid
, Printer
, Order
A printer can have many bids but only one an order.
Im having trouble validating that exact case, a printer can have many bids, but only one bid per order
Are there any validations that have this built in to ActiveModel or ActiveRecord? If not any ideas on how to ensure a printer can only have one bid per order?
class Bid < ActiveRecord::Base
belongs_to :printer
end
class Order < ActiveRecord::Base
belongs_to :user
has_many :bids
end
class Printer < ActiveRecord::Base
has_many :orders, through: :bids
has_many :bids
end