我有一个方法返回:
format.json { render :json => @call, :include => :customer }
但是,我希望@call.created_at
作为更易读的日期时间返回。
我该怎么做?
感谢
答案 0 :(得分:1)
您可以在模型中创建一个方法来美化时间。
class Call < ActiveRecord::Base
def formatted_time
#Pretty time
end
end
format.json { render :json => @call, :include => :customer, :methods => :formatted_time }