Skip to content

has_one and has_many association throw[ wrong number of arguments (given 1, expected 0)] when passed with proc shortcut #399

@mayankkumarji

Description

@mayankkumarji

I had rails 4.2 and ruby 2.3.5 and I'm upgrading it to rails 5.2 with ruby 2.6.1. With older rails version(4.2) my UserAuthenticatedSerializer is working fine and was giving proper response. After upgrading to rails 5.2
my Serializer throwing argument error. I debugged it and it's throwing from relationship.rb file, method name fetch_id and fetch_associated_object Here in both methods, object_block.call(record, params) throwing me argument error. If I remove second parameter params it works fine but passing this two arguments causing me error.
This same association work with rails 4.2 but it's not working in rails 5.2.
Here is my code snap :
response = UserAuthenticatedSerializer.new(@user, { params: { domain: current_domain } }).to_json
error = ArgumentError (wrong number of arguments (given 1, expected 0))
#user_authenticated_serializer.rb ===>

class UserAuthenticatedSerializer
  include FastJsonapi::ObjectSerializer
  has_one :user_profile, serializer: UserProfileSerializer, &:user_profile
  has_many :user_topic_label_order, &:user_topic_label_order
end

#user.rb ====>
Relationship in user model:

has_one  :user_profile, dependent: :destroy
has_many :user_topic_label_order, dependent: :destroy

Rails version : 5.2.2
Ruby version : ruby 2.6.1
fast_jsonapi gem version : fast_jsonapi (1.5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions