Guest User

Untitled

a guest
Oct 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. class Exam has_many :questions
  2. has_and_belongs_to_many :users
  3.  
  4. class Question has_many :answers
  5. has_many :user_answers
  6. belongs_to :exam
  7.  
  8. class Answer belongs_to :question
  9.  
  10. class UserAnswer belongs_to :question
  11. belongs_to :user
  12.  
  13. class User has_and_belongs_to_many :exams
  14. has_many :user_answes
  15.  
  16. answer = Answer.find(params[:id])
  17. user_answer = UserAnswer.create(answer_id: answer.id, user_id: user.id, question_id: answer.question.id)
Add Comment
Please, Sign In to add comment