search for: insert_dashes

Displaying 1 result from an estimated 1 matches for "insert_dashes".

2011 May 24
4
Rails hates my recursive function
...* in the form "adam smith" The goal is to allow my users to enter either names separated by a space, or the student id number into a single search field and have the results be returned based on the format of the query. I came up with the following code in my student model def self.insert_dashes(term) if /^([A-Z]|[a-z]|\d|-){11}$/.match(term) term.insert 3, ''-'' term.insert 6,''-'' end end def self.find_record(rec) if /^([A-Z]|[a-z]|\d|-){11}$/.match(rec) student=Student.where(:studentID=>rec).all elsif /^([A-Z\s]|[a-z\s])+$/.match(rec...