Monthly Archives: January 2009

Rails date validation freak on blank

When I have a date that can be nil, I usually end up needing the following code, which I’ve monkey patched into ActiveRecord::Base: private   def string_to_date(value) value = case value when blank? then nil when Date then value else begin Date.parse(value) rescue nil rescue nil end end end Afterward, I simply use the awesome [...]

noop Firebug for other browsers

If you’ve left console.log statements in your code intentionally or by mistake, the following will allow a successful noop in browsers for which Firebug is either not installed, disabled, or uninstallable. liaison.util.firebug = function() { (function() { if(!window.console) { console = {}; console.log = Ext.emptyFn; } })(); };