Class: AffiliationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/affiliations_controller.rb

Overview

Handles the Provider's ability to manipulate Affiliations

Instance Method Summary (collapse)

Instance Method Details

- (Object) create



15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/affiliations_controller.rb', line 15

def create

  # This check is necessary because users may attempt to POST without using our hyperlinks.
  if current_user.is_a? Provider
    @affiliation = Affiliation.new(provider_id: current_user.id, customer_id: params[:affiliation][:customer_id])
    @affiliation.save
  end

  # We go back to the affiliations path whether the save was successful or not.
  redirect_to affiliations_path

end

- (Object) destroy



28
29
30
# File 'app/controllers/affiliations_controller.rb', line 28

def destroy
  # TODO: Handle destroying {Affiliation}s. (This isn't difficult, but isn't a core part of Iteration 3.)
end

- (Object) index



7
8
9
# File 'app/controllers/affiliations_controller.rb', line 7

def index
	@affiliations = current_user.affiliations
end

- (Object) new



11
12
13
# File 'app/controllers/affiliations_controller.rb', line 11

def new
	@affiliation = Affiliation.new
end