0

I am using Rails 4.1.14.2 and FriendlyId 5.0.3

I have a Project class that has multiple Topics. Topic slugs need to be unique across all topics within the same project.

My routes are like localhost/:project/sub-topic-slug

Topics class uses friendlyId and an STI table table has SubTopics class Topic extend FriendlyId friendlyId :slug_candidates, use: :scoped, scope: :project

SubTopic1 < Topic

FriendlyId is allowing slugs to be same for the SubTopic1 and SubTopic2. When I look at the SQL generated for scope it is automatically adding type column from the STI. But the documentation says that slugs will not be unique per subclass by default. How can I change this behavior?

Looking at the source code the method "scope_for_slug_generator":

in slugged.rb uses: scope = self.class.base_class.unscoped

but in scoped.rb uses: relation = self.class.unscoped.friendly

Thanks.

LearingRoR
  • 11
  • 3

0 Answers0