i have app list , email models many many association. want users able add many emails lists @ once, have function in controller split emails custom textfield in new list form "emails" array. i want validation error if it's blank added custom validation on field in lists model: class list < applicationrecord has_and_belongs_to_many :emails #tried adding ", validates: false" here too, didn't work #custom attr_accessor :emails validates :emails, presence: true end it works great, except when try associate existing email list (in case user entered 1 in db), validation error. oddly, can prevent validation error when associating net new emails lists "(validation: false)" seen below, not when email exists already, if add save function , append "validation: false". part of controller in question is: emails.each |email| if email.where(email: email).blank? db_email = email.new( email: email ) db_email...
Comments
Post a Comment