Closed mathieumahe closed 9 years ago
That might be possible. It's hard to say without digging into the bowels of arel again. Is there something that using the select scope rather than the columns option to find_json gives you?
It would be easier to use with other gem, like has_scope, inherited_resource or datagrid.
It would also be nicer in controllers responding to html and json. The code would be DRYer!
And it will work with (default_)scope without duplications!
When running
or
I have a strange result (due to the presence of the select scope). For exemple, the second query creates the following sql statement :
select row_to_json(t) from (SELECT "messages"."id", "messages"."author_id", "messages"."author_id" FROM "messages" WHERE "messages"."id" = 732) t
and the following json :"{\"id\":732,\"author_id\":11992,\"author_id\":11992}"
I think, the find_json and all_json should be based on the select field if any. Idem for the include maybe ?
Awesome gem, by the way, I love the idea of creating json from the db!