I have Locations models - countries/regions/cities which have in total 50k plus records. i have added the configuration to these models.
Is there a way through the command line i can create the slugs for these models at one go instead of editing and saving all the models.
Save
To help you further - @iceman
is right - you need to loop through your slugged
models & save them again. friendly_id
recommends this by doing it in the rails console
:
$ rails c
$ Location.find_each(&:save)
This should help Rails load each of the items, and then save them immediately. This will trigger the slug
generation functionality of friendly_id
, populating the slug
columns of your Location
records
friendly_id updates the slug on save-ing. I did it like this for my project, but that only included about 5k items, so this works but could take some time depending on your setup.
Model.all.map(&:save)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With