website stat

Be careful with Rails reserved words

They truly mean it!

It took me almost one hour trying to figure out why Model.save was gracefully failing. save! was throwing an InvalidRecord exception but with no details whatsoever on what could be the issue.

The reason was a method valid? that I wrote on that precise model and that was returning false. Rails uses a method called, err, guess what, valid? to check whether the model validates, and since my method was returning false on creation it was blocking saving the record.


No Responses to “Be careful with Rails reserved words”

Comments are closed.