I am limiting to 1, so I thought it would simple return an object in this case the same as .find_by_email
Code:
# GET /users/:identified/type/:social_type
# Returns a single record - so limit 1
def find
@user = User.where("identified = ? AND social_type = ?", params[:identified], params[:social_type]).limit(1)
if not @user.empty?
render json: @user.as_json, status: :created
else
render json: @user, status: :not_found
end
end
Current Response:
[{"id":7,"voy_num":null,"voy_pin":null}]
How can ensure I return a single JSON object?
.firstwith 'where' clause query will do the trick.@user = User.where("identified = ? AND social_type = ?", params[:identified], params[:social_type]).first