mysql - Validating Uniqueness within data in another Table -


i have student , student_section model. student table have student_id , roll_no, student_section have student_id, standard_id , section_id.

roll_no should unique in standard , section.

in student.rb file i'm having trouble setting custom validation roll_no unique in standard , section present in student_section model.

i'm having trouble implementing, can help?

if using rails 4, can define relation of model , if true, duplcates omitted collection.

has_many :student_sections, -> { uniq }, through: :students 

and if using rails < 4 version, try this

has_many :student_sections, :through => :students, :uniq => true 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -