Closed softwaregravy closed 8 years ago
Where do you need this version, and why? The example you give above is in your BaseController, but if that controller gets called, you know your version: it's the version of that controller (V20130701 in the example).
Let me know....
More of a code-duplication thought.
If I could pull it out of the request and not hard-code it, then I could define the versions in one place -- the routes file. It's just another moving piece that would be nice to remove.
Was there any resolution on this issue?
@dan-corneanu Not really. I think it would be trivial to add something like this, but I'm still curious as to the use cases where you'd need this.
The goal was just not to have the String in the routes file, and also in the class. It's a minor point, but requires having the same string in a couple of places.
It's been a long time since I opened this. Since I never followed up answering Brian's very prompt response to my original question, it must not have been that important.
(But I will add a thank you to @bploetz for providing the package and maintaining it)
I'm not sure if this is a feature request or a help request.
I've decided to use versionist for my api routing and active_model_serializers to manage my presentation of my objects in the json object. I'm using https://github.com/hookercookerman/active_model_version_serializers so that I can version my model serialization (no context with that gem needed to understand this issue).
I have a common base class for all my controllers of a given version, and right now it looks like this:
The
version
arg there tellsactive_model_version_serializers
what version to use unless told otherwise. It matches my version from my routes file.I would love to be able to get the current versionist module from the request somehow. I would like to get this from a standard place. That is agnostic to what options I've set up versionist with (header vs url param).
As an example, I'd be able to do something like:
Where
api_version
is a helper method added toActionController::Base
. I'm pretty indifferent to the mechanism used (params? env?), but I would like to get the version of the current request.Thanks,
Adding routes.rb snippet just in case: