Activerecord associations as JSON with Grape
问题 Is there a simple way to return activerecord models with associations as JSON using the Grape microframework? get 'users' do User.includes(:address) end This snippet isn't working and User.includes(:address).to_json(include: :address) will get encoded twice as JSON. (To use the to_json method on my own doesn't feel right anyway) 回答1: You might want to use #as_json instead. So you can do User.includes(:address).as_json(include: :address) and that gives you a hash instead of a json string. 回答2: