-=
On Sun, Jan 24, 2010 at 9:24 PM, Andree Surya <[email protected]> wrote:
> Hi all,
>
> In my controller, I have an action to render JSON string containing
> current user's account information, except for his ID and hashed
> password. This is the snippet:
>
> # Fetch the account information of the current user
> def fetch_data
>
> record = User.find session[:user_id]
>
>
First, the above statement returns an instance of User,
> render :json =>
> {
> :success => true,
> :data => (record.to_json(:except => [:id, :password]))
> }
> end
>
> It does not work. The :data attribute contains a JSON string instead of
> an object.
> Sample output:
>
> {"success":true,"data":"{\"name\":\"The
> Administrator\",\"username\":\"admin\",\"role\":\"admin\"}"}
>
> How can I fix this?
>
>
The above seems correct based on your render statement. What's the problem?
-Conrad
> Thanks.
> --
> 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]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
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.