开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜