hashid-rails
hashid-rails copied to clipboard
model-level-config not working through ActiveRecord_Relation
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")