Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

rails makes it *impossible* to use any 3rd party json libs to generate pretty json

#5787

Reported by ara.t.howard · October 11th, 2010 @ 05:55 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Ryan Bigg
    Ryan Bigg
    • State changed from new to incomplete
    • Importance changed from to Low

    If you'd like this fixed in Rails please attach a patch as per the http://guides.rubyonrails.org/contributing_to_rails.html guide.

    October 11th, 2010 @ 11:32 PM

  2. ara.t.howard
    ara.t.howard

    i'm not exactly sure what you mean. the 'patch' is just not to require 'json'. if one does that all the tests pass - of course.

    this isn't something one can really fix with tests. should it submit a patch for each version of the json gem? for some a given test will fail and, for others, different tests will fail. not many, but 1 or 2 different ones. i'm pretty sure you aren't suggesting submitting a patch that test all permutations of gems one might possibly load - right?

    more problematic is that, but requiring and alternate json gem the user is asserting that he wants different json generation/parsing - that's the whole point.

    so, i guess i'm not following. there is no bug, just bad form on rails part which is really hard to fix on the user end: the code is marked with the comment 'hack' - which it is. the fix is simply to remove the hack.

    October 12th, 2010 @ 01:29 AM

  3. Ryan Bigg
    Ryan Bigg
    • State changed from incomplete to invalid

    So it's unpatchable and untestable and only results in problems if somebody requires 'json', which makes it a non-Rails issue?

    Sorry, can't help you.

    October 12th, 2010 @ 03:12 AM

  4. Ryan Bigg
    Ryan Bigg
    • State changed from invalid to incomplete

    If you want to see this fixed: please suggest an alternative.

    October 12th, 2010 @ 03:13 AM

  5. ara.t.howard
    ara.t.howard

    the alternative is simple: rather than

    1) requiring the json gem and then clobbering all it's code

    do instead

    2) do nothing. let the json gem maintainers provide bug fixes for rails compatibility

    as it stands now it's just a massive hack (as the author states in the code). not only does it literally require a gem and then clobber it's method to death, but it introduces dependency issues since it does the hack outside of bundler and then loads the app inside of bundler - aka it can result in two json verions being loaded/blowing up.

    all i'm saying is that it would be more clean to remove the code marked 'hack', which breaks no tests, and then to let actual bug reports come in (to rails or json.gem) than to make the person yelling foul provide alternatives when none are needed...

    summary: do nothing.

    it works fine, just slightly differently (as intended) when the json gem is loaded - user beware! actually, maybe that is the best approach: issue a warning after initialize if the json gem has been loaded... hrm.

    October 12th, 2010 @ 03:23 AM

  6. ara.t.howard
    ara.t.howard

    ps. if you've ever worked on an extensive /api you'll see just how nice using JSON.pretty_generate in development actually is - it saves hours of debugging time. and, of course, it is way faster.

    October 12th, 2010 @ 03:25 AM

  7. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 19th, 2010 @ 08:26 AM

  8. Santiago Pastorino
    Santiago Pastorino
    • State changed from incomplete to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:48 PM

  9. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:48 PM