class OrgCoursesController < ApplicationController def create org_ids = params[:orgNames] @course = Course.find(params[:course_id]) org_ids.each do |org_id| if OrgCourse.where("organization_id =? and course_id =?", org_id.to_i, params[:course_id].to_i).count == 0 OrgCourse.create(:organization_id => org_id.to_i, :course_id => params[:course_id].to_i, :created_at => Time.now) end end respond_to do |format| format.js end end def destroy @course = Course.find(params[:course_id]) @org_course = OrgCourse.find(params[:id]) @org_course.destroy end end