• R/O
  • HTTP
  • SSH
  • HTTPS

auto_scope: Repository summary

(Rails plugin) Automatic add some named_scope before find, last, first and all.


Recent Commits RSS

Rev. Time Author Message
0fdb751 2009-12-09 14:51:41 (del#39370) master initialize repository

Branches

Name Rev. Time Author Message
master 0fdb751 2009-12-09 14:51:41 (del#39370) initialize repository

README

AutoScope
===========

Automatic add some named_scope before find, last, first and all.

Example
=======

Setting:

  ActiveRecord::AutoScope.configure do |c|
    c.attach(:company)
    c.attach(:department)
  end

  ActiveRecord::Schema.define(:version => 0) do
    create_table :people do |t|
      t.string :name
      t.string :company
      t.string :department
      t.timestamps
    end
  end

  class Person < ActiveRecord::Base
    auto_scope
  end

And:

  Write named_scope 'company' and 'deparment' in somewhere (ex. plugin)

Then:

  Person.find(:first, :conditions => {:name => 'alice'})
  #=> Person.company.department.find(:first, :conditions => ... )


Copyright (c) 2009 Good-Day, Inc

Show on old repository browser