I would like to add some text to a model when the json object is returned. For example
format.json { render :json => @user.to_json, :status => 200 }
The @user model contains a field called website. The user websites are in the format www.mysite.com, but I want the resulting json to display http://www.mymysite.com.
For example, there could be thousands of users.
@users = User.all
format.json { render :json => @users.to_json, :status => 200 }
I don't want to go through all the users and update the website column one by one. Is there a way to define this in the model where the returned value of website is http:// + self.website?
The more I research this it looks like I would override the method def as_json(options = {}), but I'm not sure how to do it to modify the website field.