Sha256: c774d30ef8d42e18f486fe9252c3797d4bbab15182b94f73333b50df25345569

Contents?: true

Size: 935 Bytes

Versions: 5

Compression:

Stored size: 935 Bytes

Contents

class Student < ActiveRecord::Base
  has_and_belongs_to_many :subjects
  has_many :grades
  has_many :parents
  belongs_to :pet, polymorphic: true

  def report_card
    subjects.map do |subject|
      grade = grades.find_by_subject_id(subject.id)
      "#{subject.name}: #{grade.value if grade}"
    end
  end
end

class Parent < ActiveRecord::Base
  belongs_to :student
end

class Location < ActiveRecord::Base
  validates :slug, format: {with: /\A[a-z0-9\-]+\z/}
end

class Subject < ActiveRecord::Base
  has_and_belongs_to_many :students
end

class Grade < ActiveRecord::Base
  belongs_to :student
  belongs_to :subject
end

class Account < ActiveRecord::Base
  has_many :parents
  has_many :students
  has_many :subjects
  has_many :grades
  has_many :locations
  has_many :cats
  has_many :owls
end

class Cat < ActiveRecord::Base
  has_one :student, as: :pet
end

class Owl < ActiveRecord::Base
  has_one :student, as: :pet
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
abstract_importer-1.3.4 test/support/mock_objects.rb
abstract_importer-1.3.3 test/support/mock_objects.rb
abstract_importer-1.3.2 test/support/mock_objects.rb
abstract_importer-1.3.1 test/support/mock_objects.rb
abstract_importer-1.3.0 test/support/mock_objects.rb