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
Namespacing outgoing requests w/ Rails convention #117
Comments
possibly something like https://gist.github.com/7d0a00c2c03e5a053144 ? |
Why not just override toJSON on your own models? |
I think I agree with collin about this for the time being. Adding a line like:
is only slightly easier than doing this:
Let's leave things as they are for the time being, and if this arises as a common question, we can add an option for it. Also note that you can accomplish the same thing for all of your models at once by overriding |
Won't that mess up the collection toJSON though? Seems a bit weird to have the endpoint config tweak up the json representation of things...? |
It depends on what your endpoint is expecting. If you'd like to discuss this in a livelier fashion, feel free to pop in to |
Thanks for the IRC chat. We'll try overriding toJSON or Backbone.sync. For posterity:
Since the models don't know their own names we can't just tweak Backbone.sync and be done -- we have to go through and configure the models to at least know their names. Which is doable of course. |
Putting the solution for this into the documentation would be really nice. Awesome framework, by the way. |
If someone who's using Backbone with a Rails app in the "standard" style wants to put together a paragraph detailing the best way to get things integrated -- I'd be glad to drop it in the FAQ on the homepage. |
Please reopen this issue. There should either be documentation on how to set this up with the Rails conventions, which are logical and sane defaults. (No one wants an update action for every little attribute on a model, just one update action is fine thank you.) Or this should be reviewed to go into core https://gist.github.com/7d0a00c2c03e5a053144 |
(note: this is different than the "include_root_in_json" question)
Is there a way to namespace attributes on the outgoing PUT/POST requsts that backbone makes? e.g. to follow the Rails convention of:
rather than
?
We're integrating backbone into our existing app which has a bunch of endpoints following the former convention. If there's not a way right now would you be willing to accept a patch for it?
The text was updated successfully, but these errors were encountered: