This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
.manifest | ||
| |
LICENSE | ||
| |
README | ||
| |
Rakefile | ||
| |
TODO | ||
| |
init.rb | ||
| |
lib/ | ||
| |
scoped_search.gemspec | ||
| |
test/ |
README
scoped_search
=========================================================
This simple plugin will make it easy to search your ActiveRecord models.
A simple example to demonstrate its use:
--
class Project < ActiveRecord::Base
searchable_on :name, :description
end
Project.search_for(params[:q]).each { |project| ... }
--
This functionality is build on named_scope. The searchable_on statement creates
a named_scope "search_for". Because of this, you can actually chain the call with
other scopes. For example, this can be very useful if you only want to search in
projects that are accessible by a given user.
--
class Project < ActiveRecord::Base
searchable_on :name, :description
named_scope :accessible_by, lambda { |user| ... }
end
# using chained named_scopes and will_paginate
Project.accessible_by(current_user).search_for(params[:q]).paginate(:page => params[:page], :include => :tasks)
--
The search query language is simple. It supports these constructs:
- words: some search keywords
- phrases: "a single search phrase"
- negation: "look for this" -"but do not look for this phrase and this" -word
This Rails plugin is written by Willem van Bergen for the Floorplanner.com website.
It is released under the MIT license. Please contact me if you have any suggestions
or remarks.







