I am using Ruby on Rails 3 and I would like to override the to_json
method.
At this time I use the following code in order to avoid to export important information.
def to_json
super(
:except => [
:password
]
)
end
If I want change a value using that method, how I can do?
For example, I would like to capitalize the user name
:name => name.capitalize
on retrieving this
@user.to_json