Skip to content

Friendly_id with inheritance

Nico edited this page Jun 25, 2014 · 3 revisions

Case:

Say you have this classes:

class User < ActiveRecord::Base
  extend FriendlyId
  friendly_id :name, :use => [:slugged, :finders]
end

class SpecificUser < User
end

In order to find by slug:

specific_user = SpecificUser.find "jon-snow"

We need to explicitly define the use of friendly_id finder plugin inside SpecificUser

class SpecificUser < User
  friendly_id :name, :use => [:finders]
end

This is because each class has its own Friendly_id configuration and is not inherited.

Clone this wiki locally