0

I have a method returning this:

  format.json  { render :json => @call, :include => :customer }

However, I want the @call.created_at to return as a more readable datetime.

How can I do that?

thanks

1 Answer 1

1

You can create a method in your model to prettify the time.

class Call < ActiveRecord::Base
  def formatted_time
    #Pretty time
  end
end

format.json  { render :json => @call, :include => :customer, :methods => :formatted_time }
Sign up to request clarification or add additional context in comments.

2 Comments

shouldn't this work: def formatted_time this.created_at = this.created_at.strftime("%d--%m--%Y") end ?
no just def formatted_time this.created_at.strftime("%d--%m--%Y") end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.