Thank you. On Saturday, August 17, 2019 at 11:46:19 PM UTC-5, Jeremy Evans wrote: > > On Saturday, August 17, 2019 at 6:50:02 AM UTC-7, craig buchanan wrote: >> >> 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? >> > > Make the database columns NOT NULL, and use the auto_validations plugin. > That's probably the easiest way. > > Thanks, > Jeremy > > >
-- 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/4485c493-b373-4c7b-b965-3f7e7521ee67%40googlegroups.com.
