Sha256: 05ff58a0440afb50fdb04ee434ac990b886d938f0f3b49a25cba93d2913c56ea

Contents?: true

Size: 1.64 KB

Versions: 76

Compression:

Stored size: 1.64 KB

Contents

module DeveloperProjectsAssociationExtension
  def find_most_recent
    find(:first, :order => "id DESC")
  end
end

module DeveloperProjectsAssociationExtension2
  def find_least_recent
    find(:first, :order => "id ASC")
  end
end

class Developer < ActiveRecord::Base
  has_and_belongs_to_many :projects do
    def find_most_recent
      find(:first, :order => "id DESC")
    end
  end
  
  has_and_belongs_to_many :projects_extended_by_name, 
      :class_name => "Project", 
      :join_table => "developers_projects", 
      :association_foreign_key => "project_id",
      :extend => DeveloperProjectsAssociationExtension

  has_and_belongs_to_many :projects_extended_by_name_twice, 
      :class_name => "Project", 
      :join_table => "developers_projects", 
      :association_foreign_key => "project_id",
      :extend => [DeveloperProjectsAssociationExtension, DeveloperProjectsAssociationExtension2]

  has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id'

  validates_inclusion_of :salary, :in => 50000..200000
  validates_length_of    :name, :within => 3..20
end

DeveloperSalary = Struct.new(:amount)
class DeveloperWithAggregate < ActiveRecord::Base
  self.table_name = 'developers'
  composed_of :salary, :class_name => 'DeveloperSalary', :mapping => [%w(salary amount)]
end

class DeveloperWithBeforeDestroyRaise < ActiveRecord::Base
  self.table_name = 'developers'
  has_and_belongs_to_many :projects, :join_table => 'developers_projects', :foreign_key => 'developer_id'
  before_destroy :raise_if_projects_empty!

  def raise_if_projects_empty!
    raise if projects.empty?
  end
end

Version data entries

76 entries across 76 versions & 6 rubygems

Version Path
jstorimer-deep-test-2.0.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/developer.rb
jstorimer-deep-test-1.4.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/developer.rb
jstorimer-deep-test-1.3.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/developer.rb
jstorimer-deep-test-1.2.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/developer.rb
jstorimer-deep-test-1.1.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/developer.rb
jstorimer-deep-test-1.0.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/developer.rb
jstorimer-deep-test-0.2.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/developer.rb
jstorimer-deep-test-0.1.0 sample_rails_project/vendor/rails/activerecord/test/fixtures/developer.rb
activerecord-1.15.3 test/fixtures/developer.rb
activerecord-1.15.4 test/fixtures/developer.rb
activerecord-1.15.0 test/fixtures/developer.rb
activerecord-1.15.1 test/fixtures/developer.rb
activerecord-1.15.2 test/fixtures/developer.rb
activerecord_authorails-1.0.0 test/fixtures/developer.rb
backlog-0.0.0 vendor/rails/activerecord/test/fixtures/developer.rb
backlog-0.0.1 vendor/rails/activerecord/test/fixtures/developer.rb
backlog-0.0.2 vendor/rails/activerecord/test/fixtures/developer.rb
backlog-0.0.5 vendor/rails/activerecord/test/fixtures/developer.rb
backlog-0.0.4 vendor/rails/activerecord/test/fixtures/developer.rb
backlog-0.1.0 vendor/rails/activerecord/test/fixtures/developer.rb