RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Save All Empty Strings as NIL

Save All Empty Strings as NIL WHERE field IS NULL OR field = ‘’ no more… Rails plugin that converts all empty strings to nil when saving. Avoids lots of query/performance/syntax problems. Includes migration to clean your existing records.

Comments

preview works great :D

It’s just a JavaScript copy from textbox to showing the HTML. No sanitization. The title box does say not to put HTML in it ;-)

Oracle treats empty strings as NULL already (i.e. they become NULL on insert or update). I’m pretty sure Postgres does, too.

Maybe you should reconsider your RDBMS.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in