Skip to content

Instantly share code, notes, and snippets.

@alvadorn
Forked from Emethium/all_the_stuff.rb
Last active March 19, 2017 13:47
Show Gist options
  • Select an option

  • Save alvadorn/8875d343f5371520d3927ea6dce19817 to your computer and use it in GitHub Desktop.

Select an option

Save alvadorn/8875d343f5371520d3927ea6dce19817 to your computer and use it in GitHub Desktop.
Lesson halp
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
class ClassTime < ApplicationRecord
belongs_to :lesson
end
class Lesson < ApplicationRecord
has_many :students, :through => :sessions
has_many :class_times
validates :name, presence: true, length: {maximum: 256}
validates :number_of_students, presence: true, numericality: { only_integer: true }
end
class Session < ApplicationRecord
belongs_to :student
belongs_to :lesson
end
class Student < ApplicationRecord
#attr_accessor :name, :registration, :address, :phone_number, :last_payment
has_many :lessons, :through => :session
validates :name, presence: true, length: {maximum: 256}
validates :registration, presence: true, length: {maximum: 12}
validates :address, presence: true, length: {maximum: 256}
validates :phone_number, presence: true, length: {maximum: 256}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment