class OrgProjectsController < ApplicationController def create org_ids = params[:orgNames] @project = Project.find(params[:project_id]) org_ids.each do |org_id| if OrgProject.where("organization_id =? and project_id =?", org_id.to_i, @project.id).count == 0 OrgProject.create(:organization_id => org_id.to_i, :project_id => params[:project_id].to_i, :created_at => Time.now) end end respond_to do |format| format.js end end def destroy @project = Project.find(params[:project_id]) @org_project = OrgProject.find(params[:id]) @org_project.destroy end end