class ProductLang < ActiveRecord::Base belongs_to :product_category belongs_to :product_collection #validates :slug, :uniqueness => {:scope => :lang} before_validation do self.slug = self.title.to_slug errors.add(:title, 'doit être présent') if !title? and self.lang == "fr" errors.add(:title, 'doit être présent') if !slug? and self.lang == "fr" end end