This is built for 0.9, and is a first-pass at getting Rails' url_helpers into the serializers. The current approach is a bit tied to Rails, but makes the helpers directly accessible w/in any instance of ActiveModel::Serializer. This also works for associations.
An idea I have for an alternative approach is to expose the URL helpers via a urls method available from serializer instances, rather than mixing the url_helpers directly into ActiveModel::Serializer. This would at least provide a seam for non-Rails apps to implement their own solution, while still relying on a Serializer.urls API. I could try that here to in a different pull request, if it's desired. Or we could roll with this for now and try that when/if needed.
The Travis failures are on Ruby 2.1.0, and look to be due to a Bundler bug, which has been fixed in Bundler 1.5.1, but Travis is still running 1.5.0.
@spastorino after rebasing on your latest changes for embedding, these tests suddenly fail. I'm pulling my hair out trying to figure out why... can you take a look and see if you spot something?
👍 will check this as soon as I can. We have a long list to finish before so please hold on with this one. Thanks for the work BTW :)
@spastorino Figured it out; a bug with passing options to associations. Fixed in #483.
@stevenharman 👍 let me think about all this
The more I think about it, and considering the goal not wanting to be tied to Rails, I prefer the alternative approach in #481 to this one. That said, both still need some work, so if you like one or the other, let me know and I'll focus on polishing them up (and making sure the work with latest master).
When runnin w/in Rails, make available url_helpers
This technique ties this usage to Rails, which but makes the helpers
directly accessible w/in any instance of ActiveModel::Serializer,
including any associations.
I'd be interested in either one, and there's also one other open PR to add url support... I think I'd prefer the alternative, too, so let's close this.
@stevenharman This is pretty great. Any chance I can help you resurrect this?