OSDN Git Service

initialize repository
[traxi/auto_scope.git] / README.ja
1 AutoScope
2 ===========
3
4 find, first, last, allの呼び出し時に自動的にNamed Scopeの呼び出しを行います.
5
6 Example
7 =======
8
9 Setting:
10
11   AutoScope.configure do |c|
12     c.attach(:company)
13     c.attach(:department)
14   end
15
16   ActiveRecord::Schema.define(:version => 0) do
17     create_table :people do |t|
18       t.string :name
19       t.string :company
20       t.string :department
21       t.timestamps
22     end
23   end
24
25   class Person < ActiveRecord::Base
26     auto_scope
27   end
28
29 次に:
30
31   pluginなどでアタッチしたNamed Scopeを記述します.
32
33 すると:
34
35   Person.find(:first, :conditions => {:name => 'alice'})
36   # => Person.company.department(:first, :conditions => ... )
37
38
39 Copyright (c) 2009 Good-Day, Inc
40