Ruby complex validation
Posted
by pcasa
on Stack Overflow
See other posts from Stack Overflow
or by pcasa
Published on 2010-05-07T18:44:24Z
Indexed on
2010/05/07
18:48 UTC
Read the original article
Hit count: 207
ruby-on-rails
|ruby
Have a product that belongs to a category. Want to create a promotion for a short period of time (lets say a week or two), but their can be only one promotion per category during that time.
How can I create a custom validation for this?
product class
belongs_to :categories
name:string
desc:text
reg_price:decimal
category_id:integer
promo_active:boolean
promo_price:decimal
promo_start:datetime
promo_end:datetime
end
category class
has_many :products
name:string
end
© Stack Overflow or respective owner