Thursday, August 23, 2012

Extend Ruby core class in Rails application

Follow the ActiveSupport convention, create extension file in lib/core_extensions/[class].rb.
e.g. lib/core_extensions/date.rb

Then, require the file when needed.
e.g. require 'lib/core_extensions/date'

Or put the require statement in any of the config/initializers/ file.


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.