Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed bug where respond_with was sending back improperly structured json #95

Merged
merged 2 commits into from
Nov 18, 2011

Conversation

ewpeters
Copy link

uploader.js was expecting a json response that looked like '{"image": "{..model attributes...}"}'. respond_with was sending '{.....model attributes.....}'

@jejacks0n
Copy link
Owner

Nice man.. so, two questions. The first, I understand that it's ok to remove the Mercury:: namespacing for the image model, but I've run into issues with that in the past -- eg. it thinks you want something that's namespaced deeper. Do you have any insight that I'm not aware of?

The second, is that I'm not seeing this.. is it a specific version of rails, or what?

I'd just like some clarification on those before I merge this.

Thanks again. =)

@ewpeters
Copy link
Author

  1. Oops, no insights, I am currently overriding the functionality in my project and it wasn't playing nice with the name spacing, so when I copy pasted it screwed up. I added a commit

  2. I'm not sure, I'm running Rails 3.1.1 if that helps

jejacks0n added a commit that referenced this pull request Nov 18, 2011
fixed bug where respond_with was sending back improperly structured json
@jejacks0n jejacks0n merged commit 8ee9702 into jejacks0n:master Nov 18, 2011
@jejacks0n
Copy link
Owner

So this broke it for me -- and likely others who started with rails 3.1? Not fully sure, but we don't have something in our initializers that you have, and that's why this has been a bit confusing to me.

I tracked it down, and here are the details:

In this rails generator file, which is within railties 3.1.1 you can see that it sets ActiveRecord::Base.include_root_in_json to false.. That's not altogether bad, as it's system wide, but it's also not altogether good because it's system wide with no way to override it in a given scenario. So, yes, this is probably the root of the issue you're trying to solve, but this fix might not work for everyone. :-/

I'm rolling most of this back in a following commit and will add the logic to check the two places on the client.. unless you see a better way in rails? Besides telling people they should add ActiveRecord::Base.include_root_in_json = true to their initializers -- potentially breaking other aspects of their site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants