I have the following and am not sure why it doesn’t work. It outputs the whole location object.
def test
@l=Location.find(12)
render :json => @l.as_json(only: [:id, :name])
end
How do I limit to only id and name? I don’t want to use respond_to or respond_with block.
thx
Does this work?
I want to edit my answer. I think this is the correct way to do it.