Class: Locomotive::MembershipsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/locomotive/memberships_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



14
15
16
17
18
19
20
21
# File 'app/controllers/locomotive/memberships_controller.rb', line 14

def create
  authorize Membership
  if @membership = service.create(membership_params[:email])
    respond_with @membership, location: edit_current_site_path(current_site), flash: true
  else
    redirect_to (email: membership_params[:email])
  end
end

#destroyObject



33
34
35
36
37
# File 'app/controllers/locomotive/memberships_controller.rb', line 33

def destroy
  authorize @membership
  @membership.destroy
  respond_with @membership, location: edit_current_site_path
end

#editObject



23
24
25
# File 'app/controllers/locomotive/memberships_controller.rb', line 23

def edit
  respond_with @membership
end

#newObject



8
9
10
11
12
# File 'app/controllers/locomotive/memberships_controller.rb', line 8

def new
  authorize Membership
  @membership = current_site.memberships.build
  respond_with @membership
end

#updateObject



27
28
29
30
31
# File 'app/controllers/locomotive/memberships_controller.rb', line 27

def update
  authorize @membership
  self.service.change_role(@membership, membership_params[:role])
  respond_with @membership, location: edit_current_site_path
end