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?
You need to have respond_to block, otherwise it doesn't know the format to send back.
respond_to do |format|
if exist_user
format.json { render json: {:msg => 'has this user'} }
else
end
end
Check out this for more detail, http://api.rubyonrails.org/classes/ActionController/Responder.html