Ask A Question

Notifications

You’re not receiving notifications from this thread.

Mapping API Resources & Handling Pagination Discussion

Looks like the code in this episode has evolved over time, I'm watching it (paid my subscription too) in 2022, post pandemic, and the source code is quite different now at GitHub, where can I find the logic behind the code evolution? Thanks, great content, definitely worth the subscription

Reply

Looks like there is nobody here anymore, but I'm going to post this request for help anyway... I'm getting this error from ostruct and don't know how to solve it (NoMethodError)

hash.each_pair do |k, v|
    ^^^^^^^^^^
from /Users/lflores/.asdf/installs/ruby/3.1.0/lib/ruby/3.1.0/ostruct.rb:128:in `initialize'
from /Users/lflores/Laboratory/RailsLab/pli_third_parties_api_wrapper/lib/pli_third_parties_api_wrapper/object.rb:6:in `initialize'
from /Users/lflores/Laboratory/RailsLab/pli_third_parties_api_wrapper/lib/pli_third_parties_api_wrapper/resources/users.rb:6:in `new'
from /Users/lflores/Laboratory/RailsLab/pli_third_parties_api_wrapper/lib/pli_third_parties_api_wrapper/resources/users.rb:6:in `show'
from (irb):3:in `<main>'
from bin/console:22:in `<main>'

I will try using 'respond_to(:each_pair) to cut the recursivity call to 'to_ostruct(val)'... whish me luck ...

Reply

I can't see enough code to give a solid reply, but most likely you are trying to return an array of objects, in which case you need to use the Collection class to map as an array first.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.