How would I construct this validation rule?

Hi, I have this model,

class EcOrder < ActiveRecord::Base
has_many :ec_line_items
validates_associated :ec_line_items

end

and what I want to do is construct a validation rule that says an
order is not valid unless it has one or more line items. The error
message would read, “An order must have at least one item.” How would
I construct such a rule?

Thanks, - Dave

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs