I have 3 models User, Club and Mcq.
In club model. I assign club (class) as -
- 9-physics
- 9-chemistry
- 10-physics
- 10-chemistry...
Here is my Association
class User < ActiveRecord::Base
has_and_belongs_to_many :clubs
end
class Club < ActiveRecord::Base
has_many :mcqs
has_and_belongs_to_many :users
end
class Mcq < ActiveRecord::Base
belongs_to :club
end
In my student view (student show index) I show all club (as subject) and after click on a subject I just want to show Mcq topic of that related subject.
for that my Club Controller is -
class ClubsController < ApplicationController
#its show subject list
def student_show_index
@club = current_user.clubs
end
#its show topic according to subject.
def student_show_topic
@club = current_user.clubs
@mcq = @club.first.mcqs.order('created_at DESC')
end
end
So my question is, when I click on subject physics it show all the Mcq of 9th. and same for chemistry.
I just want to filtered Mcq according to subject.