Create parametrized scopes on Note to remove code duplication
The following discussion from !17818 (merged) should be addressed:
-
@nolith started a discussion: (+3 comments) Why don't we get the opportunity to get rid of this
CodeReuse/ActiveRecord
?The offenders are
notes.where('(note LIKE ? OR note LIKE ?)', text, text.capitalize)
and
notes.where(note: [text, text.capitalize])
We may consider adding a couple of parametrized scope in
Note
like the followings (naming could be improved😄 )scope :for_note, ->(text) { where(note: [text, text.capitalize]) } scope :like_note, ->(text) { where('(note LIKE ? OR note LIKE ?)', text, text.capitalize) }