In a rails app I have an action that returns a json string. It looks something like this:
if exist_user
format.json { render json: {:msg => 'has this user'}}
else
but rails show error:too few arguments
How do I render custom json string?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to have
respond_toblock, otherwise it doesn’t know the format to send back.Check out this for more detail, http://api.rubyonrails.org/classes/ActionController/Responder.html