• R/O
  • HTTP
  • SSH
  • HTTPS

auto_scope: Zusammenfassung des Repository

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


Neueste Commits RSS

Rev. Zeit Autor Nachricht
0fdb751 2009-12-09 14:51:41 (del#39370) master initialize repository

Zweige

Name Rev. Zeit Autor Nachricht
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