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 a proper response.
After upgrading to rails 5.2 my Serializer started throwing an 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 an argument error.
If I remove the second parameter from the params it works fine. Passing these two arguments causes an 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) active_model_serializers (~> 0.10.9)