Code Monkey home page Code Monkey logo

Comments (3)

stas avatar stas commented on August 25, 2024

@omerpucit thanks for the report, but I don't see how this is related to jsonapi.rb.

In fact, it's pretty clear that the error is somewhere within the way you set up things:

NoMethodError - undefined method `book.author_name' for #<Book

If it helps, I'm happy to review the serializer for the Book, but there's little else I can do to help here.

I'll be closing this, but feel free to follow-up if you find anything I did miss.

from jsonapi.rb.

omerpucit avatar omerpucit commented on August 25, 2024

The issue was with the nested objects ( and with the rails method -> errors_object.generate_message ). Anyway, I have already fixed it for my own case.

attribute :detail do |object, params|
      error_key, error_hash = object
      errors_object = params[:model].errors
      # Rails 4 provides just the message.
      if false && error_hash[:error].present? && error_hash[:error].is_a?(Hash)
        message = errors_object.generate_message(
          error_key, nil, error_hash[:error]
        )
      elsif false && error_hash[:error].present?
        message = errors_object.generate_message(
          error_key, nil, error_hash
        )
      else
        message = error_hash[:message]
      end

      errors_object.full_message(error_key, message)
    end

from jsonapi.rb.

stas avatar stas commented on August 25, 2024

@omerpucit we do not support, nor plan to support nested resources/errors. And I generally do not recommend this pattern.

Glad you worked it out 🙏

from jsonapi.rb.

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.