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

with_role returns all the records more than expected #597

Open
siddushar opened this issue Jan 16, 2024 · 0 comments
Open

with_role returns all the records more than expected #597

siddushar opened this issue Jan 16, 2024 · 0 comments

Comments

@siddushar
Copy link

I have the following Active record relationship in my application

class Client < ApplicationRecord
  resourcify
end

class SupportGroup < ApplicationRecord
  resourcify
end


class User < ApplicationRecord
end

I'm using rolify gem 5.x.

The actual problem is.
I have around 6k SupportGroup records in my Postgres db and I have na user 'xyz'. he is not bound to any of the support groups as an approver.
But using the following query I'm getting all 6k records

user = User.find_by!(name: 'xyz') supported_by_ids = SupportGroup.with_role(:approver, user).pluck(:id)

Expected behavior:
I should not be getting an supported_by_ids as the user('xyz') is not bound to any support group as an approver

@siddushar siddushar changed the title with_role returns all aata more than expected with_role returns all the records more than expected Jan 16, 2024
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

1 participant