Changing the default value for the Rails option Option option Hide option

Does anyone know how to change the default setting for Date.parse (which ActiveRecord uses in all date fields). I would like the default “comp” for true, so I don't need to consider 2- in my application.

http://corelib.rubyonrails.org/classes/Date.html#M001228

+3
source share
1 answer

You can overload / disarm an existing method. eg:

class Date
  class << self
   alias :parse_with_comp :parse
  end
  def self.parse(str='-4712-01-01', sg=ITALY)
    self.parse_with_comp(str,true,sg) 
  end
end
+1
source

All Articles