We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Rails 4.0.2, FriendlyId 5.0.2
Config:
config.use Module.new { def should_generate_new_friendly_id? slug.blank? || new_record? end }
Test Result:
b1=FactoryGirl.create(:building) b1.slug #=> "building-1" b2=FactoryGirl.build(:building, neighbourhood: b1.neighbourhood, name: b1.name) b2.send(:set_slug) Building Exists (0.8ms) SELECT 1 AS one FROM "buildings" WHERE "buildings"."neighbourhood_id" = 4 AND "buildings"."slug" = 'building-2' LIMIT 1 #=> "building-1--91415ad1-565b-43d6-9a4b-e8a23df3c041" b2.send(:set_slug) Building Exists (0.6ms) SELECT 1 AS one FROM "buildings" WHERE "buildings"."neighbourhood_id" = 4 AND ("buildings"."id" <> NULL) AND "buildings"."slug" = 'building-2' LIMIT 1 #=> "building-1"
Model:
class Building include FriendlyId belongs_to :neighbourhood friendly_id :name_en, use: [:scoped], scope: :neighbourhood end
The text was updated successfully, but these errors were encountered:
Failed test added PikachuEXE@a958dc9
Sorry, something went wrong.
No branches or pull requests
Rails 4.0.2, FriendlyId 5.0.2
Config:
Test Result:
Model:
The text was updated successfully, but these errors were encountered: