Created
July 2, 2015 07:07
-
-
Save dnsilva/3e24e4ad0519558b2529 to your computer and use it in GitHub Desktop.
Generate json for object with associations rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup_custom_json_for_datagrid(shops) | |
json_data = shops.to_json(only: [:id, :name], include: { concept: { only: :name, include: { chain: { only: :name} } } }) | |
jsonResponse = "{\"current\": #{params[:current]}, \"rowCount\": #{params[:rowCount]}, \"rows\": #{json_data}, \"total\": #{shops.length}}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment