Fmt Alias

Simply create virtual fields to humanize real field values.

Installation

Add the following line to your Gemfile:

gem 'fmt_alias'

Example

Let the News model have created_at column:

class News < ActiveRecord::Base
  date_fmt_alias(:d, "%Y%m%d")
  date_fmt_alias(:dt, "%Y%m%d %H:%M")
end

news = News.new
news.d_fmt = "20090101"
news.d == Date.new(2009,1,1) # true
news.d_fmt                   # 20090101