Giter Site home page Giter Site logo

active_model_version_serializers's People

Contributors

hookercookerman avatar leemhenson avatar sjfbo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

active_model_version_serializers's Issues

How can I do versioning dynamic?

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?

Anyone get this working on Heroku?

I have it working fine on my own dev box, and it responds with different versions just fine. When I push it to Heroku it's only using v1, even though v2 is the default.

Not sure if it's me or if there is Heroku caching issues. Anyone try that yet?

AMS root element configuration not respected

There is an issue when root element is configured this way :

ActiveSupport.on_load(:active_model_serializers) do
  # Disable for all serializers (except ArraySerializer)
  ActiveModel::Serializer.root = false
  # Disable for ArraySerializer
  ActiveModel::ArraySerializer.root = false
end

Actually the gem is doing that :

    def self.version(version, superclass = ActiveModel::Serializer, &block)
      base_class = self
      vklass = Class.new(superclass) do
        self.root(base_class._root)
        alias_method base_class._name.to_sym, :object

        singleton_class.class_eval do
          define_method(:to_s) do
            "(#{base_class.name} VERSION: #{version})"
          end
          alias inspect to_s
        end

It sets root (or not) directly based on parameters passed to the serializer :

[1] poc_api_app(#<Class>) »  superclass
=> ActiveModel::Serializer < Object
[2] poc_api_app(#<Class>) »  superclass._root?
=> false
[3] poc_api_app(#<Class>) »  base_class
=> UserSerializer < ActiveModel::VersionSerializer
[4] poc_api_app(#<Class>) »  base_class._root?
=> true

You can notice that it doesn't use my configuration and still includes the root element because it doesn't check if superclass._root? is false.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.