ruby on rails - Shoulda: unknown error with validates_each -


i'm having awful time trying understand validation method having trouble with.

i installed shoulda , when tried use it errors out strange undefined method nomethoderror: undefined method '[]' false:falseclass odd.

i narrowed down piece of offending code:

validates_each :name |record, attr, value|   name_hash = self.parse_name(value)   record.errors.add attr, 'must have first , last name' if     ( name_hash[:first_name].nil? || name_hash[:last_name].nil? ) end 

you can see full error, offending model (simplified), test case, , environment info @ gist-596202

any insight appreciated.

your parse_name method starts line:

return false unless name.is_a?(string) 

this indicate value not string (probably nil) when you're trying validate it. shoulda matcher validate_presence_of test nil value, why you're getting failure.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -