rsl / stringex

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

Open peritpatrio opened 8 years ago

peritpatrio commented 8 years ago

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:

peritpatrio commented 8 years ago

Apparently running rake test did not run all tests.