1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class BusinessCardsController < ApplicationController

  def index
    render :json => BusinessCard.order("created_at DESC").all
  end

end

class BusinessCard < ActiveRecord::Base

  def to_json(args={})
    Rails.logger.info("calling to_json in BusinessCard")
    super(:methods => :formatted_date, :except => :date)
  end

  def as_json(args={})
    Rails.logger.info("calling as_json in BusinessCard")
    super(:methods => :formatted_date, :except => :date)
  end

  def formatted_date
    date.strftime("%b %d, %Y")
  end

end