"has_many"
"has_many" . , . , teacher_id, , .
"belongs_to"
"" . , . , , , .
, /.
class Teacher < ActiveRecord::Base
has_many :students, dependent: :destroy
end
class Student < ActiveRecord::Base
belongs_to :teacher
end
,
Teacher.destroy
, .
Teacher.find(345).destroy
345 .
, , , ?
class Teacher < ActiveRecord::Base
has_many :students, dependent: :destroy
end
class Student < ActiveRecord::Base
belongs_to :teacher, dependent: :destroy
end
Student.destroy
, . , (, ), , , "".
Ruby 1
: destroy, , . , property_to has_many - .