In rails, how can I find out what caused a .save() to fail, other than validation errors?

kdt picture kdt · Jan 17, 2011 · Viewed 58.2k times · Source

I have an ActiveRecord model which is returning true from valid? (and .errors is empty), but is returning false from save(). If the model instance is valid, how can I find out what's causing the save to fail?

Answer

Andy Lindeman picture Andy Lindeman · Jan 17, 2011

Try using the bang version save! (with an exclamation mark at the end) and inspecting the resulting error.