Sha256: 33ad1ced51320550752ce619ceac64c4f9c82353836a5f4d5e9bb13989b71116

Contents?: true

Size: 329 Bytes

Versions: 52

Compression:

Stored size: 329 Bytes

Contents

class Person < ActiveRecord::Base
  has_many :animals do
    def pups
      find(:all, :conditions => 'age < 1')
    end
    def adults
      find(:all, :conditions => 'age >= 1')
    end
  end
  validates_presence_of :name
  
  def add_animal animal
    animal.person = self
    animals << animal
    animal.save
  end
    
end

Version data entries

52 entries across 52 versions & 10 rubygems

Version Path
cavalle-rspec-rails-1.2.2.0.1 spec/resources/models/person.rb
cavalle-rspec-rails-1.2.2.0.2 spec/resources/models/person.rb
cavalle-rspec-rails-1.2.3.1 spec/resources/models/person.rb
cavalle-rspec-rails-1.2.4.0.1 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.11.4 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.11.5 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.11.6 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.11.7 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.12 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.99.1 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.99.13 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.99.2 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.99.3 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.99.4 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.99.5 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.99.6 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.99.7 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.99.8 spec/resources/models/person.rb
dchelimsky-rspec-rails-1.1.99.9 spec/resources/models/person.rb
mcmire-rspec-rails-1.1.99.9 spec/resources/models/person.rb