Given a ProductRating class:

class ProductRating < Sequel::Model
  plugin :validation_helpers

  many_to_one :person 
  many_to_one :product 

  def validate
    super
    validates_presence [:rating]
    validates_includes (1..5).to_a, :rating
  end

end

If I want to ensure that a Person and a Product have been assigned to the 
instance, would need to just add two, additional validations?


validates_presence [:person_id]
validates_presence [:product_id]


Is there a way to force this in the associations?  Is there a better way?

Thanks.


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/f8ea215e-cee0-41f7-bb56-b9a6349b6e55%40googlegroups.com.

Reply via email to