rails 3 json not rending user id
I have a simple @user = User.all
User has firstName, lastName, email and all the devics stuff.
But when I render it as json, I don't get the user.id. Just get all the other info.
format.json { render :json => @users, :except => [:encrypted_password, 开发者_如何学Go:last_sign_in_at, :last_sign_in_ip, :reset_password_sent_at, :reset_password_token, :remember_created_at, :sign_in_count], :include => [:profile, :authentications] }
use @users.to_json(:except....), not @users, except
see the API reference
I suspect Rails doesn't provide the ID to try and help against mischievous use.
The usual way is to have a different key for use with objects in the API.
精彩评论