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

Records not returning original class #912

Closed
patodevilla opened this issue Oct 25, 2019 · 2 comments
Closed

Records not returning original class #912

patodevilla opened this issue Oct 25, 2019 · 2 comments
Labels

Comments

@patodevilla
Copy link

I am using cancancan for authorizations in my rails app. In this code, the ES query returns some records that I already now I am allowed to visualize. I was scratching my head because cancancan always returned false when running the can? method.

records = Elasticsearch::Model.search(query, models).records.records records = records.select{|r| can?(:show, r)}

Then I noticed that if I have a model 'Test' and run records.first.class == Test it returns false!
I think this is the issue that is causing cancancan to always return false

ability.rb

can [:show] Test

I called .to_s.constantize in Elasticsearch::Model::Adapter::Multiple::Records__type_for_hit and fixed it.

Does anyone think this can be considered a bug?

@stale
Copy link

stale bot commented Aug 31, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@SeanLF
Copy link

SeanLF commented Apr 29, 2021

Can this issue be re-opened?

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

No branches or pull requests

2 participants