Class: SummerResidents::ResidentsController

Inherits:
SummerResidentsController show all
Defined in:
app/controllers/summer_residents/residents_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
# File 'app/controllers/summer_residents/residents_controller.rb', line 6

def create
  create_resident_and_assign_to_family
  assign_resident_attributes
  @resident.user = User.initialize_without_password(params[:email])
  success = @resident.save
  EasyRailsAuthentication::AuthenticationHelper.SendPasswordInitializationEmailTo @resident.email if success
  show_unless_errors success
end

#destroyObject

DELETE /residents/1 DELETE /residents/1.json



38
39
40
41
42
43
44
# File 'app/controllers/summer_residents/residents_controller.rb', line 38

def destroy
  Resident.find(params[:id]).destroy
  
  respond_to do |format|
    format.js { render nothing: true }
  end
end

#editObject



20
21
22
23
24
# File 'app/controllers/summer_residents/residents_controller.rb', line 20

def edit
  @resident = Resident.find(params[:id])
  set_type
  edit_but_show_if_cancelled
end

#newObject



15
16
17
18
# File 'app/controllers/summer_residents/residents_controller.rb', line 15

def new
  create_resident_and_assign_to_family
  edit_but_show_if_cancelled
end

#updateObject

PUT /residents/1 PUT /residents/1.json



28
29
30
31
32
33
34
# File 'app/controllers/summer_residents/residents_controller.rb', line 28

def update
  @resident = Resident.find(params[:id])
  assign_resident_attributes
  @resident.user.email = params[:email].blank? ? nil : params[:email]
  set_type
  show_unless_errors @resident.save
end