Created
January 16, 2015 14:26
-
-
Save goldnuggets24/cc9feec349c32e416883 to your computer and use it in GitHub Desktop.
Get first 4 items returned from db where title matches searched criteria
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@items += Item.where( "lower(title) ~* ?", "#{params[:s].downcase}".split(/,\s*/).map(&:strip).reject(&:empty?).first) | |
@items += Item.where( "lower(title) ~* ?", "#{params[:s].downcase}".split(/,\s*/).map(&:strip).reject(&:empty?).second) | |
@items += Item.where( "lower(title) ~* ?", "#{params[:s].downcase}".split(/,\s*/).map(&:strip).reject(&:empty?).third) | |
@items += Item.where( "lower(title) ~* ?", "#{params[:s].downcase}".split(/,\s*/).map(&:strip).reject(&:empty?).fourth) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just thought of something dumb... I guess (at the very least) I could probs make the first half of this statement a variable and re-use that way...