Class: UserMembershipsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
app/controllers/user_memberships_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/user_memberships_controller.rb', line 6

def create
  #This should pull from current_organization
  @organization = Organization.find(params[:organization_id])
  authorize! :manage, @organization

  with_user do |user|
    build_membership(user, @organization) or build_errors(user, @organization)
  end

  redirect_to organization_url(@organization) and return
end

#destroyObject



18
19
20
21
22
23
24
# File 'app/controllers/user_memberships_controller.rb', line 18

def destroy
  @organization = Organization.find(params[:organization_id])
  @mship = UserMembership.find(params[:id])
  authorize! :manage, @organization
  @mship.destroy
  redirect_to organization_url(@organization), :notice => "User has been removed from #{@organization.name}" and return
end

#newObject



2
3
4
# File 'app/controllers/user_memberships_controller.rb', line 2

def new
  @organization = Organization.find(params[:organization_id])
end