Some [hopefully] useful extensions to Ruby’s String class. It is made up of three libraries: ActsAsUrl [permalink solution with better character translation], Unidecoder [Unicode to Ascii transliteration], and StringExtensions [miscellaneous helper methods for the String class].
MIT License
984
stars
158
forks
source link
Load taken urls from db instead of complete objects #182
We have a scenario where there might be 1000 records in database with the same title. When saving the 1001st one, currently acts_as_urls loads 1000 records to see which number it should append to the end of the url slug. Naturally this causes some issues with memory when there are lots of records.
Changes made
This PR changes it so that only the url slugs are loaded into the memory rather than complete objects.
Few notes:
I'm not really familiar with the codebase but all current tests seem to pass
Issue #176 is somewhat related, but this does not solve the problem mentioned regarding fetching all records.
Premise
We have a scenario where there might be 1000 records in database with the same title. When saving the 1001st one, currently acts_as_urls loads 1000 records to see which number it should append to the end of the url slug. Naturally this causes some issues with memory when there are lots of records.
Changes made
This PR changes it so that only the url slugs are loaded into the memory rather than complete objects.
Few notes: