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
rspec-rails-1.1.12 spec/resources/models/person.rb
rspec-rails-1.2.5 spec/resources/models/person.rb
rspec-rails-1.2.1 spec/resources/models/person.rb
rspec-rails-1.2.3 spec/resources/models/person.rb
rspec-rails-1.2.6 spec/resources/models/person.rb
rspec-rails-1.2.4 spec/resources/models/person.rb
rspec-rails-1.2.2 spec/resources/models/person.rb
spree-0.6.0 vendor/plugins/rspec-rails/spec/resources/models/person.rb
spree-0.7.1 vendor/plugins/rspec-rails/spec/resources/models/person.rb
spree-0.7.0 vendor/plugins/rspec-rails/spec/resources/models/person.rb
spree-0.8.0 vendor/plugins/rspec-rails/spec/resources/models/person.rb
spree-0.8.1 vendor/plugins/rspec-rails/spec/resources/models/person.rb