Class: Peoplefinder::PeopleController

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

Instance Method Summary collapse

Instance Method Details

#add_membershipObject



61
62
63
64
65
# File 'app/controllers/peoplefinder/people_controller.rb', line 61

def add_membership
  set_person if params[:id].present?
  @person ||= Person.new
  render 'add_membership', layout: false
end

#createObject

POST /people



29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/peoplefinder/people_controller.rb', line 29

def create
  @person = Person.new(person_params)

  if @person.valid?
    confirm_or_create
  else
    error :create_error
    render :new
  end
end

#destroyObject

DELETE /people/1



54
55
56
57
58
59
# File 'app/controllers/peoplefinder/people_controller.rb', line 54

def destroy
  @person.send_destroy_email!(current_user)
  @person.destroy
  notice :profile_deleted, person: @person
  redirect_to home_path
end

#editObject

GET /people/1/edit



24
25
26
# File 'app/controllers/peoplefinder/people_controller.rb', line 24

def edit
  @person.memberships.build if @person.memberships.empty?
end

#indexObject

GET /people



9
10
11
# File 'app/controllers/peoplefinder/people_controller.rb', line 9

def index
  redirect_to '/'
end

#newObject

GET /people/new



18
19
20
21
# File 'app/controllers/peoplefinder/people_controller.rb', line 18

def new
  @person = Person.new
  @person.memberships.build group: group_from_group_id
end

#showObject

GET /people/1



14
15
# File 'app/controllers/peoplefinder/people_controller.rb', line 14

def show
end

#updateObject

PATCH/PUT /people/1



41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/peoplefinder/people_controller.rb', line 41

def update
  @old_email = @person.email
  @person.assign_attributes(person_params)

  if @person.valid?
    confirm_or_update
  else
    error :update_error
    render :edit
  end
end