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]

  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?

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].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to