hookercookerman / active_model_version_serializers

Versioning For ActiveModel::Serializer
MIT License
7 stars 4 forks source link

How can I do versioning dynamic? #5

Closed orafaelfragoso closed 9 years ago

orafaelfragoso commented 10 years ago

Hi,

I'm using a namespaced route to version my API:

namespace :api do
    namespace :v1 do
    end
end

I already configured my Serializer with this gem but the documentation is not clear enough and I don't know where to specify the serializer version dynamically.

I want them to load the right version based on the namespace 'v1, v2...'. How can I do that?

hookercookerman commented 10 years ago

HI; its been a long time since I looked at this; you can parse a version option either when using render method at the controller level; as that will pass the options along;

render @user, {version: 2}

or even better is at the controller level namespace you could define

def default_serializer_options
  {
    version: 2
  }
end

I think from reading latest docs; 0.8 will be looking to remove options so not sure how it could work then; but then I am not sure how one would change the root option either;

anyway hope this helps

orafaelfragoso commented 9 years ago

+1