Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `arity' #24

Open
nhcfk opened this issue Feb 5, 2021 · 6 comments
Open

undefined method `arity' #24

nhcfk opened this issue Feb 5, 2021 · 6 comments

Comments

@nhcfk
Copy link

nhcfk commented Feb 5, 2021

I'm getting: undefined method `arity' for {:class_name=>"Person", :optional=>true, :foreign_key=>"father_id"}:Hash

I'm using Ruby 3.0.0 and Rails 6.1.1. Followed all the install steps and added indexes, still crashing with said message. The entry point for the error is has_parents on person.rb.

Any ideas?

@masciugo
Copy link
Owner

masciugo commented Feb 5, 2021

it's not tested against ruby 3 and rails 6.1. could you try with ruby 2 and rails 6.0?

@nhcfk
Copy link
Author

nhcfk commented Feb 5, 2021

Tested working with Ruby 2.6.3 and Rails 6.0.
Can't really find anything useful online on the error.

@masciugo
Copy link
Owner

masciugo commented Feb 6, 2021

I cannot investigate this currently. However I would try to find out if it's caused by last rails or last ruby firstly. I guess I may be able to debug this not earlier than 2 weeks sorry. Let me know if you find anything

@nhcfk
Copy link
Author

nhcfk commented Feb 24, 2021

So, basically, I'm still stuck, I don't really have much experience debugging.

Currently, I'm stuck in this file active_record/associations/builder/association.rb.

I landed there from genealogy.rb around line 98:

      tracked_relatives.each do |k|
        belongs_to k, belongs_to_options.merge(foreign_key: self.send("#{k}_id_column"))
      end

I ran diffs on both active_record/associations/builder/association.rb and active_record/associations/builder/belongs_to.rb from the working ActiveRecord version 5.2.1 and the one crashing 6.1.1 and there are a few differences but even then I'm not able to spot what might be causing the problem.

on binding.pry at line 53 of association.rb :

    52: def self.build_scope(scope)
 => 53:   binding.pry
    54:   if scope && scope.arity == 0
    55:     proc { instance_exec(&scope) }
    56:   else
    57:     scope
    58:   end
    59: end

The scope being:

[1] pry(ActiveRecord::Associations::Builder::HasOne)> scope
[1] pry(ActiveRecord::Associations::Builder::HasOne)> scope=> #<Proc:0x00007fcbc8373d90 /Users//.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/activestorage-6.1.1/lib/active_storage/attached/model.rb:70 (lambda)>

I then checked active_storage/attached/model.rb and noticed I get stopped on line 70 where: name is :profile_picture coming from my User model (has_one_attached :profile_picture).

70: has_one :"#{name}_attachment", -> { where(name: name) }, class_name: "ActiveStorage::Attachment", as: :record, inverse_of: :record, dependent: :destroy, strict_loading: strict_loading

This particular file has got quite a bit differences with the 5.2.1 version diff here

I'd really wish I could help some more but I'm afraid I reached my limit in this regard.

Regards,
Nelson

@masciugo
Copy link
Owner

Thank you for your effort but I would not go so deep right now. First of all I can confirm that the arity problem is related to ruby3 and not to rails 6.1. Is ruby3 a requirement for you?

@nhcfk
Copy link
Author

nhcfk commented Feb 25, 2021

Is ruby3 a requirement for you?

Not really, TBH. I took the whole thing down to 2.7.2
It's working as expected now so I'll stay out of 3 for now.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants