Open mayankkumarji opened 5 years ago
Hi @mayankkumarji,
Could you explain what are &:user_topic_label_order
and &:user_profile
params being passed for? I have a feeling those are causing issues.
Hi @shishirmk : Yeah, I have explained in title that this proc shortcuts(&:user_profile, &:user_topic_label_order) is causing me error, you can see both are the associate model with User model and relation is like
has_one :user_profile, dependent: :destroy
has_many :user_topic_label_order, dependent: :destroy
@mayankkumarji this is going to be difficult to debug without looking at the proc definitions and more details. Also you never changed the version of fast_jsonapi? Was it always 1.5?
@shishirmk : Okay, I need to provide you a working demo. Yes version of fast_jsonapi was always 1.5.
@shishirmk : Please find working demo here fast-json I have created.
Setup Instruction link and issue reproduce https://github.com/mayankkumarji/fast-json-demo/wiki/Setup-Instruction
I was able to reproduce the issue. I am looking into it. It might have been a change in behavior from active record. Why are you passing the proc? It looks like it works if you just don't pass the proc at all. If you dont have custom logic in this proc i don't understand the need to even pass it.
class UserAuthenticatedSerializer
include FastJsonapi::ObjectSerializer
attributes :name, :address
has_one :user_profile
end
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
andfetch_associated_object
Here in both methods,object_block.call(record, params)
throwing me argument error. If I remove second parameterparams
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 ===>
user.rb ====>
Relationship in user model:
Rails version : 5.2.2 Ruby version : ruby 2.6.1 fast_jsonapi gem version : fast_jsonapi (1.5)