Git Product home page Git Product logo

Comments (11)

drn avatar drn commented on May 26, 2024 1

Thanks for providing that project, @ivan-garanin

I dug into our source code via your project and it looks like neither this gem or active_model_serializers have great support for non-ActiveRecord ORMs. Both gems key off of collection resources responding to a to_ary method that ActiveRecord has implemented for collections, but Sequel does not.

That said, I implemented some basic support for sequel that you can try out.
#74

I tested this against your project:

gem 'grape-active_model_serializers',
  github: 'ruby-grape/grape-active_model_serializers',
  branch: 'support-sequel'

Let me know if it works for you!

from grape-active_model_serializers.

drn avatar drn commented on May 26, 2024 1

v1.5.1 has been released!

from grape-active_model_serializers.

ivan-garanin avatar ivan-garanin commented on May 26, 2024

Here is my base grape file

module Nsi
  class API < Grape::API
    format :json
    formatter :json, Grape::Formatter::ActiveModelSerializers

    mount Nsi::DictionaryResource
    mount Nsi::ParameterResource
    mount Nsi::DictionaryParameterResource

    add_swagger_documentation :format => :json,
                              :hide_documentation_path => true,
                              :mount_path => 'swagger_doc'
  end
end

from grape-active_model_serializers.

ivan-garanin avatar ivan-garanin commented on May 26, 2024

same error without option

each_serialize: DictionarySerializer

from grape-active_model_serializers.

ivan-garanin avatar ivan-garanin commented on May 26, 2024

Looks like i have got anonymous class a = Class.new; a.name => nil in Grape::ActiveModelSerializers::SerializerResolver in instance initialization something like Grape::ActiveModelSerializers::SerializerResolver.new(Class.new, opts)

hm... I already have got it there...

module Grape
  module Formatter
    module ActiveModelSerializers
      class << self
        def call(resource, env)
          # !!!! resource.class.name => nil, resource.class => #<Class:0x005...>
          options = build_options(resource, env)
          serializer = fetch_serializer(resource, options)

          if serializer
            ::ActiveModelSerializers::Adapter.create(
              serializer, options
            ).to_json
          else
            Grape::Formatter::Json.call(resource, env)
          end
        end

        def build_options(resource, env)
          Grape::ActiveModelSerializers::OptionsBuilder.new(
            resource, env
          ).options
        end

        def fetch_serializer(resource, options)
          Grape::ActiveModelSerializers::SerializerResolver.new(
            resource, options
          ).serializer
        end
      end
    end
  end
end

hm... I need help guys :(' What I'm doing wrong?

from grape-active_model_serializers.

drn avatar drn commented on May 26, 2024

Hi @ivan-garanin, is there a project that I would be able to reproduce this error in? If I can replicate the error, I can look into patching it

from grape-active_model_serializers.

ivan-garanin avatar ivan-garanin commented on May 26, 2024

Hi @drn , I'll publish on github my cutted project for you tomorrow.

from grape-active_model_serializers.

ivan-garanin avatar ivan-garanin commented on May 26, 2024

@drn, I made example app(with all same configs/settings and so on) https://github.com/ivan-garanin/example-for-grape_active_model_serializer check readme to launch it faster

from grape-active_model_serializers.

ivan-garanin avatar ivan-garanin commented on May 26, 2024

@drn thank you!

from grape-active_model_serializers.

drn avatar drn commented on May 26, 2024

👍 worked? ill get that merged in over the next few days and release a new gem version

from grape-active_model_serializers.

ivan-garanin avatar ivan-garanin commented on May 26, 2024

yea, everything is OK, ty for help, ping me when release ll be ready and I'd remove that ugly line from Gemfile)

from grape-active_model_serializers.

Related Issues (20)

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.