ruby on rails - determining if at least one pair of fields are filled out -


so in rails app have column of text boxes in pairs. there 4 pairs of textboxes.

just 1 of these pairs of text box needs filled out (with both textboxes in pair filled out) valid.

so i'm trying loop through them , add them multi dimensional array , check @ least 1 row(?) in array has both values.

  def no__values?     all_values = array.new     txt_a_values = array.new     txt_b_values = array.new      self.item.line_items.each |item|       txt_a_values << item.single.nil? # value text box       txt_b_values << item.aggregate.nil? # value text box b     end      all_values << txt_a_values #create multi dimensional array     all_values << txt_b_values      all_values.each |v|       ??? # there needs 1 pair in array has both values     end   end 

so should create array this

[true][true] # both textboxes nil [false][false] # both textboxes have values [true][true] # both textboxes nil [true][true] # both textboxes nil 

the above scenario valid since there 1 pair both have values

i don't way i'm progressing this, i',m looking help.

couldn't this:

def no__values?   self.item.line_items.each |item|     return false if !item.single.nil? && !item.aggregate.nil?         end    true end 

that return false when both values of pair isn't null, , returns true if each pair had @ least 1 null value.

edit:
based on method name didn't create array , instead returns false/true directly.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -