Skip to content

Records not returning original class #912

@patodevilla

Description

@patodevilla

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions