I just added the Friendly_id gem to my rails project looking to not use the database id and create a slug, but I can't seem to create slugs 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
I then am running Model.find_each(&:save)
but it keeps spitting out a nil result. I've tried commenting out the should_generate_new_friendly_id
completely but with no luck. Anyone see what I'm doing wrong here?
EDIT
I rolled my database back and rewrote my migratations and that has appeared to have fixed the issue.