Say i have this short code:
item = Item.find(params[:id])
render :json => item.to_json
but i needed to insert/push extra information to
The to_json
method takes an option object as parameter . So what you can do is make a method in your item class called as message and have it return the text that you want as its value .
class Item < ActiveRecord::Base
def message
"it works"
end
end
render :json => item.to_json(:methods => :message)