Created
September 3, 2014 15:12
-
-
Save dacur/131615e7b5b414c69e5d to your computer and use it in GitHub Desktop.
You have a search box where someone can enter a first OR last name. You need to search your database of all first names AND last names looking for the value entered. The code below is ActiveRecord's way of handling this search for you - no SQL required. See here for more info: http://stackoverflow.com/questions/3684311/rails-how-to-chain-scope-q…
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
| @vendorsfound = Vendor.where("first like ? OR last like ?", "%" + params[:first] + "%", "%" + params[:first] + "%").order("LOWER(last) ASC, first") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment