Created
June 11, 2013 02:34
-
-
Save sferik/5754135 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateUsers < ActiveRecord::Migration | |
def change | |
create_table :users do |t| | |
t.string :name | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateCourses < ActiveRecord::Migration | |
def change | |
create_table :courses do |t| | |
t.string :name | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateCourseTeachers < ActiveRecord::Migration | |
def change | |
create_table :course_teachers do |t| | |
t.integer :course_id | |
t.integer :teacher_id | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateCourseStudents < ActiveRecord::Migration | |
def change | |
create_table :course_students do |t| | |
t.integer :course_id | |
t.integer :student_id | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Course < ActiveRecord::Base | |
attr_accessible :name | |
has_many :course_students | |
has_many :students, :class_name => "User", :through => :course_students | |
has_many :course_teachers | |
has_many :teachers, :class_name => "User", :through => :course_teachers | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CourseStudent < ActiveRecord::Base | |
belongs_to :course | |
belongs_to :student, :class_name => "User" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CourseTeacher < ActiveRecord::Base | |
belongs_to :course | |
belongs_to :teacher, :class_name => "User" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
attr_accessible :name | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment