ruby on rails - How to implement ActiveRecord has_many through polymorphic association with different source types -
I have 3 models: votes, students and teacher students can vote for any other student or teacher. Earlier, a student could only vote for a student or a teacher. But now I have the option to vote for many students and teachers. Vote model additionaly is a category_ id and a rating repository, so that you can vote different rated in the same category. I use the fourth model for voting and multi-lingual relations among the teacher / student, which is called Single Vote Relation, which has been voted, voted, voted and voted.
Now I have the ability to vote. Receive and receive the collection of voting figures (student or teacher) without manually messing with the single voter table:
is_a any: Voted, via: Single_Votted_relation / < / Code>
But I get an error message when I try to do my work Do not look model:
related_to: voter, class_name: "student "Has_maya: single_ explosion_related_medium: vote Made through Ga_stutents :: Akl_visfotit relationship Srot_prkar: "student" Source :: voted Ha_maya: through Voted_teachers :: Single_voted_relations, Source_type: "teacher" Source :: voted
Single-declaration looks like this:
related_to: vote is_to: voted, polymorphic: true
student:
is_maya: given_wots, class_name: "vote", foreign_key: "voter_id" is_maya: single_ted_article, class_name: "single-divided relation", Have as :: Votes # Polimorfik has_many: achieved_votes, Source :: through the vote :: Akl_voted_snbnd
Teacher:
has_many: single_voted_relations , Class_name: "Singlvoted relations", as :: voted # Polimorfik Ha_man: Prapt_viots source :: through the vote :: Akl_voted_snbnd
I made basically only vote People want to be included in the voters' voting voters vote and voting voters vote voting, in which Students and teachers have also been included.
It can be very complicated and can be in a smart way to achieve my goal. Are different source types also possible?
Support is appreciated
Thanks!
Comments
Post a Comment