remi / her

Her is an ORM (Object Relational Mapper) that maps REST resources to Ruby objects. It is designed to build applications that are powered by a RESTful API instead of a database.
MIT License
2.05k stars 322 forks source link

Model.all returns empty array, but response has data #550

Open shabin-slr opened 12 months ago

shabin-slr commented 12 months ago

I'm getting below raw response to api calls but in variable the data is always an empty array. The api response is in JSON format. What could be the issue?

irb(main):002:0>y MyApi::MyModal.all.fetch
--- !ruby/object:Her::Model::Relation
parent: !ruby/class 'MyAPI::MyModel'
params:
  :page: 1
  :per_page: 2
_fetch: !ruby/array:Kaminari::PaginatableArray
  internal: []
  ivars:
    :@_padding: 0
    :@_total_count: 0
    :@_offset_value: 0
    :@_limit_value: 2
    :@_original_array: !ruby/array:Her::Collection
      internal:
      - !ruby/object:MyAPI::MyModel
        metadata: {}
        response_errors: {}
        destroyed: false
        attributes: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
          my_model: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
            id: 1
            first_name: Test
            last_name: Name
            phone_number: '9112345678901'
            opted_in: false
            deleted_at: 
            created_at: '2023-09-20T12:52:05.700Z'
            updated_at: '2023-09-20T12:52:05.700Z'
        changed_attributes: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
          my_model: 
      - !ruby/object:MyAPI::MyModel
        metadata: {}
        response_errors: {}
        destroyed: false
        attributes: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
          my_model: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
            id: 2
            first_name: test
            last_name: name
            phone_number: '78946513060'
            opted_in: false
            deleted_at: 
            created_at: '2023-09-20T13:14:29.363Z'
            updated_at: '2023-09-20T13:14:29.363Z'
        changed_attributes: !ruby/hash:ActiveSupport::HashWithIndifferentAccess
          my_model: 
      ivars:
        :@metadata: {}
        :@errors: {}
irb(main):002:0> MyApi::MyModal.all.fetch
=> []
pboling commented 5 months ago

This gem has some major bugs, and is essentially unmaintained since 2016. I recommend checking out https://github.com/balvig/spyke.