Skip to content

model-level-config not working through ActiveRecord_Relation #70

Open
@jfanals

Description

@jfanals

I have been trying with the new hashid_config, as I have just renamed a table that I has using with hashid-rails setting the pepper on the model. I love the functionality. Unfortunately it does not work when querying an ActiveRecord_Relation.

The hashid_config parameters are set using the model parameters correctly as long as the model is queried directly, eg:

Post.hashid_configuration
=> returns correct pepper that is set in the model

But when if the ActiveRecord_Relation is in between it does not work, eg:

Post.all.hashid_configuration
=> returns the original table_name as pepper (overriding the one set on the model)

The hashid_config gets called on the ActiveRecord_Relation, and the options are empty.

This means that this works

Post.find("hashid")

but this doesn't

Post.includes(:comments).find("hashid")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions