in my controller I currently have:
invite = Invite.find_by_token(params[:id])
user = invite.user
json_response({
user: user
})
def json_response(object, status = :ok)
render json: object, status: status
end
Right now, user is returning all user fields. I want to return just (id, email)... I've tried:
user = invite.user.select(:id, :email)
user = invite.user.pluck(:id, :email)
neither works. Ideas?
You can use the method as_json passing attributes you want in the response, like:
user.as_json(only: [:id, :email])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With