Rails, destroy if blank

Posted by Joseph Silvashy on Stack Overflow See other posts from Stack Overflow or by Joseph Silvashy
Published on 2010-06-03T00:41:25Z Indexed on 2010/06/03 0:44 UTC
Read the original article Hit count: 242

Filed under:

This might sound odd, but is there a 'Rails way' to have a model destroyed if a certain attribute is blank? Say I have a model like tags with just a name attribute or something, if the user edits the tag and deletes all the text out of the name field in the form I'd like the model to just be deleted.

I'm aware of the reject_if method, but that doesn't seem to work.

© Stack Overflow or respective owner

Related posts about ruby-on-rails