Search code examples
ruby-on-railsjsonjbuilder

Rails - json - password appearing in json response with except defined


I am having an issue getting the json I get in the response in my rails app. I've tried using an as_json method in model, I've tried using an only statement in a jbuilder file in the views folder, but no matter what I do the password (the hashed version of it) still shows up in the returned json. I believe I was doing the steps correctly but was not able to find the root cause of this. any suggestions would be appreciated. Also, when I tried the as_json method in the model options I got some strange error that included a large spit out of the javascript from the rails framework, so that is another side issue blocking me from using that option. Thanks in advance for the help.


Solution

  • I think I found the issue. I misremembered that in my rails app the password was stored under an attribute named "password_digest" not the "password" I thought it was and had used in the "as_json" method def. I have the expected output from as_json now. did not retry the other approach of using the jbuilder file.