class School < ActiveRecord::Base
has_many :teachers
has_many :courses
end
class Teacher < ActiveRecord::Base
belongs_to :school
has_many :courses
end
class Course < ActiveRecord::Base
belongs_to :teacher
belongs_to :school
set_from :teacher, targets: [:school_id], update_for_change: true
end
school = School.create
teacher = Teacher.create(school: school)
course = teacher.courses.create
course.school_id # => school.id
-
Notifications
You must be signed in to change notification settings - Fork 0
A gem make a model column set from nother
License
zhanglinjie/set_from
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
A gem make a model column set from nother
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published