views:

125

answers:

1

Is there a way of doing a find_by_x that raises an exception if the record is not found?

+2  A: 

added "!" at the end:

User.find_by_name "a" => return nil

User.find_by_name! "a" => raise error
amikazmi