-
-
Notifications
You must be signed in to change notification settings - Fork 588
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent behavior for #parse_friendly_id #970
Labels
Comments
We want to opt-in for case-insensitive slug and stumbled upon the same behavior. We use slugs without a scope, so our model Organization with class Organization < ApplicationRecord
extend FriendlyId
friendly_id :name, use: :slugged
def self.parse_friendly_id(value)
super.downcase
end
end yields
and
We run on FriendlyID: 5.4.2, Rails: 5.2.5, and Ruby 2.5.9. |
in addition to that, the example in the documentation has an instance method, not a class method:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the great work in this project 馃檱
We have opted-in the
#first_by_friendly_id
case insensitive change while upgrading to 5.4.0.With 5.4.2 released, we hope to maintain the same behavior by override
#parse_friendly_id
in our model, but we have noticed same inconsistent behavior for the finders.With the following model definition
We expect the finder to work for the following cases
But instead, the first
Product.find('FriendlyID')
works without issue, yet the second and third statement did not call the correct#parse_friendly_id
and returns exception:ActiveRecord::RecordNotFound: can't find record with friendly id: "FriendlyID"
Both
Product.includes(:skus)
andProduct.not_deleted.includes(:skus)
returnsProduct::ActiveRecord_Relation
, so I am guessing thatProduct::ActiveRecord_Relation
did not pick up#parse_friendly_id
definition fromProduct
model as expectedStrangely, if I called
Product.not_deleted.includes(:skus).parse_friendly_id('FriendlyID')
, it will return the expected resultfriendlyid
, and if I calledProduct.not_deleted.includes(:skus).find('FriendlyID')
followed by that, the query will return expected result.We are using
I've also tried moving friendly id settings into initializer with no luck
The text was updated successfully, but these errors were encountered: