Friendly_id does not create bullets for old records

I just added the Friendly_id pearl to my rails project, trying not to use the database id and create a pool, but I cannot create bullets for old records. My model looks like this.

class Mapping < ActiveRecord::Base extend FriendlyId friendly_id :title, use: :slugged # Friendly_Id code to only update the url for new records def should_generate_new_friendly_id? new_record? || slug.blank? end end 

Then I run Model.find_each(&:save) , but it continues to spill out a null result. I tried to completely comment on should_generate_new_friendly_id , but no luck. Does anyone see what I'm doing wrong here?

EDIT
I turned my database over and rewrote my migrations, and this seems to fix the problem.

+4
source share

Source: https://habr.com/ru/post/1438755/


All Articles