jferris / sconnect
- Source
- Commits
- Network (0)
- Issues (0)
- Downloads (1)
- Wiki (1)
- Graphs
-
Branch:
grouping
commit 3e11308e7b69e8324768bd1553454decaab12225
tree b5979815841f40c2ea0fa9243aab4ee0348bf7ea
parent d9d2ed6f68221fc8a03014fd853ce8451e073ac9
tree b5979815841f40c2ea0fa9243aab4ee0348bf7ea
parent d9d2ed6f68221fc8a03014fd853ce8451e073ac9
sconnect /
| name | age | message | |
|---|---|---|---|
| |
.gitignore | ||
| |
README.rdoc | ||
| |
Rakefile | ||
| |
lib/ | ||
| |
sconnect.gemspec | ||
| |
spec/ |
README.rdoc
Sconnect
Sconnect is an extension to ActiveRecord’s named_scopes that allows you to combine scopes in more interesting and useful ways.
Download
Github: github.com/jferris/sconnect/tree/master
Examples
Given the following model:
class Post < ActiveRecord::Base
named_scope :published, :conditions => { :published => true }
named_scope :titled, :conditions => "title IS NOT NULL"
named_scope :from_today, lambda {
{ :conditions => ['created_at >= ?', 1.day.ago] }
}
end
ActiveRecord provides scope chains:
# All published posts with titles Post.published.titled # All published posts from today Post.published.from_today
Sconnect extends these scopes:
# All posts that are either published or titled Post.published.or.titled # All posts that are published but not created today Post.published.not.from_today # All posts that are either published or untitled Post.published.or.not.titled # All posts from today that are either published or titled Post.published.or.titled.from_today
Author
Sconnect was written by Joe Ferris.

