https://github.com/bodacious/dog_the_data_hunter
Easily search multiple model attributes at once
https://github.com/bodacious/dog_the_data_hunter
Last synced: 7 days ago
JSON representation
Easily search multiple model attributes at once
- Host: GitHub
- URL: https://github.com/bodacious/dog_the_data_hunter
- Owner: Bodacious
- License: mit
- Created: 2010-06-21T08:55:30.000Z (almost 16 years ago)
- Default Branch: master
- Last Pushed: 2010-06-26T14:40:34.000Z (almost 16 years ago)
- Last Synced: 2025-02-28T01:47:06.963Z (over 1 year ago)
- Language: Ruby
- Homepage:
- Size: 93.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: MIT-LICENSE
Awesome Lists containing this project
README
DogTheDataHunter
================
Adds a named scope named search to any of your models. Once included, you can search on any attribute you specify.
Example
=======
You have a User model and would like to be able to search all users by either their first name, last name or email address:
class User < ActiveRecord::Base
include DogTheDataHunter
search_attributes :first_name, :last_name, :email, :exact_match => false
end
This creates a named scope on the model called "search" which you can pass a string to:
User.search("Gavin").all(:order => "last_name, first_name")
Options:
* :exact_match - Should the string that is passed be an exact match for the column data or simply LIKE it?
Copyright (c) 2010 [Gavin Morrice]("http://gavinmorrice.com"), released under the MIT license