dewski / json_builder

Rails provides an excellent XML Builder by default to build RSS and ATOM feeds, but nothing to help you build complex and custom JSON data structures. JSON Builder is here to help.
http://garrettbjerkhoel.com/json_builder/
MIT License
243 stars 52 forks source link

ActiveRecord Partials #26

Closed DanBrooker closed 11 years ago

DanBrooker commented 12 years ago

I'm using this to allow partials for active record models.

It's not a complete partial implementation to issue #13. But I thought it might be of interest.

The use of the parent views scope isn't ideal and something closer to erb's partials with locals would be better.

dewski commented 12 years ago

Thank you for the PR! At first glance it looks great, just would like to see if passing the scope to each to_builder call can be avoided first. Will check it out more sometime today.

dewski commented 12 years ago

Also, if you could add tests showing usage and catching possible edge cases that'd be great. Only thing other than that is the scope usage I mentioned above is blocking me from merging this in.

DanBrooker commented 12 years ago

I can add some tests, and check if the file exists, but in general this solution isn't particularly well fleshed out. Are there alternatives to the scope capture method I've used? Also named partials would be good.