Conrad Taylor wrote:
> The above seems correct based on your render statement. What's the
> problem?
>
> -Conrad
The data attribute should be an object, not a string.
Let's compare the difference with the following snippet:
render :json =>
{
:success => true,
:data => record # Without to_json method
}
The output will be: (the data attribute is an object)
{"success":true,"data":{"name":"The
Administrator","username":"admin","role":"admin","id":1,"password":"d033e22ae348aeb5660fc2140aec35850c4da997"}}
Instead of: (the data attribute is a string)
{"success":true,"data":"{\"name\":\"The
Administrator\",\"username\":\"admin\",\"role\":\"admin\"}"}
The problem is, I want to hide several attributes from the output, and
the only method that I know is to use :except parameter from to_json
method.
So, my objective is to get the output similiar to output #1, but without
the ID and password attribute.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.