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

Add support for nil scope values (such as deleted_at), with unit test #198

Open masonhale opened 7 years ago

masonhale commented 7 years ago

Current scope implementation fails if one or more of the scope attribute values is nil.

One may want to use nullable values as scope parameters when using stringex/acts_as_url in combination with a 'soft-delete' solution such as https://github.com/JackDanger/permanent_records

In this case, 'live' records will have a nil value for the deleted_at column, but deleted records will have a specific value. By including the deleted_at column in the acts_as_url scope, one can ensure that url slugs for live records will be unique, while also avoiding having 'deleted' records polluting the available URL space.