Last active
August 29, 2015 14:14
-
-
Save chrislerum/fc19876278945f5ac8f0 to your computer and use it in GitHub Desktop.
search snippet
This file contains 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
20 @all_products.each do |i| | |
21 if (i.description.include? params[:query]) || (i.name.include? params[:query]) | |
22 @products << i | |
23 end | |
24 end | |
#is this better?: | |
21 @products = all_products.reject do |i| | |
22 (!i.description.include? params[:query]) && (!i.name.include? params[:query]) | |
23 end | |
#or a one liner: | |
20 @products = all_products.reject {|i| (!i.description.include? params[:query]) && (!i.name.include? params[:query])} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment