railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.9k stars 2.26k forks source link

Invocation of association scopes with wrong number of arguments #3522

Closed TruffeCendree closed 2 years ago

TruffeCendree commented 2 years ago

Hello,

I am farcing an issue with my has_and_belongs_to_many association, which has a scope.

has_and_belongs_to_many :offered_services, -> { where(deleted_at: nil) }, inverse_of: :employee_informations, dependent: :destroy

When trying to edit an object with rails-admin, I get some exception:

ArgumentError - wrong number of arguments (given 1, expected 0)

This is caused by RailsAdmin::Adapters::ActiveRecord::Association#read_only? trying to invoke the scope with instance_eval, which provides an argument.

https://github.com/railsadminteam/rails_admin/blob/master/lib/rails_admin/adapters/active_record/association.rb#L87

Thanks

mshibuya commented 2 years ago

Dup of #2067.