I have a model User which is polymorphically associated with Person and Company model.
I am using friendly_id to show permalinks for both Person and Company.
Person has first_name attribute and I put the following in my model.
extend FriendlyId
friendly_id :first_name
Now when I update my existing entries then the slug gets created perfectly. But issue arises when I try creating a new use which throws a routing error.
Secondly, every person has one user and user has a username, so when I try this following command, then the update and new record both throws unknown method username for nil class error.
extend FriendlyId
friendly_id :person_permalink, use: [:slugged, :history]
def person_permalink
"#{self.user.username} #{self.name}"
end