Reputation: 565
I am Rails noob and I am trying to unsderstand this simple JSON parsing code from a tutorial. Why do I get the nil:NilClass Error? What is a NilClass?
Thanks!
app.put '/users/update' do
params = JSON.parse(request.body.read)
reqUserID = params[:id]
requestUser = Models::Persistence::User.find_by_id(reqUserID)
content_type "application/json"
puts "Hello"
puts requestUser.username
if (requestUser)
status 401
return
end
Upvotes: 0
Views: 730