class OrgMemberController < ApplicationController def org_member_autocomplete @org = Organization.find(params[:org]) @flag = params[:flag] || false respond_to do |format| format.js end end def create @org = Organization.find(params[:org]) if params[:membership].nil? @fail_hint = l(:label_blank_user_lists_for_org) else member_ids = params[:membership][:user_ids] role_id = params[:orgRole] member_ids.each do |user_id| member = OrgMember.create(:user_id=>user_id, :created_at => Time.now) @org.org_members << member OrgMemberRole.create(:org_member_id => member.id, :role_id => role_id) end end respond_to do |format| format.js end end def update @member = OrgMember.find(params[:id]) #@member.change_role params[:org_member][:role_ids] @member_role = @member.org_member_roles[0] @member_role.role_id = params[:org_member][:role_ids][0] @member_role.save @org = @member.organization respond_to do |format| format.js end end def new end def destroy member = OrgMember.find(params[:id]) @org = member.organization member.destroy respond_to do |format| format.js end end def index end end