Ruby on rails 4 召集协会

Ruby on rails 4 召集协会,ruby-on-rails-4,Ruby On Rails 4,我有两个表,coursescourse_id和name,staff staff_id和name与HABTM关系的关联,以及一个带有course_id和staff_id的联接表。我想显示正在教授特定课程的员工,但不确定如何操作。有什么灵魂愿意指出这一点吗 我通过这个网站创建了这个协会 <% for staff in Staff.find(:all) %> <div> <%= check_box_tag "course[staff_ids][]", staff.id,

我有两个表,coursescourse_id和name,staff staff_id和name与HABTM关系的关联,以及一个带有course_id和staff_id的联接表。我想显示正在教授特定课程的员工,但不确定如何操作。有什么灵魂愿意指出这一点吗

我通过这个网站创建了这个协会

<% for staff in Staff.find(:all) %>
<div>
<%= check_box_tag "course[staff_ids][]", staff.id, @course.staffs.include?(staff) %>
<%= staff.name %>
</div>
现在,我希望它只显示选定框,而不显示其余未选中框。下面是数据库迁移代码

class CreateCourses < ActiveRecord::Migration
 def change
  create_table :courses do |t|
      t.string :course_code
      t.string :course_name
      t.integer :year_of_study
      t.string :discipline
      t.integer :Acad_unit
      t.integer :cohort_size
      t.text :remark

      t.timestamps
    end
  end
end

class CreateStaffs < ActiveRecord::Migration
  def change
    create_table :staffs do |t|
      t.string :name
      t.string :phone
      t.string :email
      t.string :designation
      t.string :department
      t.string :location
      t.text :remark

      t.timestamps
    end
  end
end

 class ScheduleCourse < ActiveRecord::Migration
  def change
    create_table :scheduleCourse do |t|
      t.belongs_to :course
      t.belongs_to :staff
    end
  end
end

如果你已经编写了模型:Staff.findid.courses

这个问题有无数个答案,但是了解你的具体情况将有助于缩小可能的答案范围。你能展示一些关于如何创建表以及在哪里显示表的代码吗?更新了一些代码。。希望它能解释清楚问题的确切答案。