ruby on rails - How to validate for Uniqueness of more than one fields from two related tables -



ruby on rails - How to validate for Uniqueness of more than one fields from two related tables -

i having problem in validating uniqueness of multiple fields. have next models:

class classschedule < activerecord::base belongs_to :course_assignment_section end class courseassignmentsection < activerecord::base belongs_to :course_assignment has_many :class_schedules end class courseassignment < activerecord::base belongs_to :instructor has_many :course_assignment_sections, :dependent => :destroy end class instructor < activerecord::base has_many :course_assignments end

when creating class_schedule, want check uniqueness validation of 2 fields, period_id , instructor_id, period_id field found in class_schedules table, , instructor_id field can found through: course_assignment_section.course_assignment.instructor have course_assignment_section_id field in class_schedules table). how can validate uniqueness of 2 fields different tables. appreciate quick help. thanks.

ruby-on-rails ruby-on-rails-3 validation ruby-on-rails-3.2

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -