-
Notifications
You must be signed in to change notification settings - Fork 13
/
profiles_controller.rb
66 lines (55 loc) · 1.44 KB
/
profiles_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class ProfilesController < ApplicationController
load_and_authorize_resource
before_action :set_profile, only: [:show, :edit, :update, :destroy]
# GET /profiles
def index
@profiles = Profile.all
end
# GET /profiles/1
def show
end
# GET /profiles/new
def new
@profile = Profile.new
flash.keep(:event_id)
end
# GET /profiles/1/edit
def edit
end
# POST /profiles
def create
@profile = Profile.new(profile_params)
@profile.user_id = current_user.id
if @profile.save
if flash[:event_id]
redirect_to new_application_letter_path(:event_id => flash[:event_id])
else
redirect_to @profile
end
else
render :new
end
end
# PATCH/PUT /profiles/1
def update
if @profile.update(profile_params)
redirect_to @profile, notice: 'Profile was successfully updated.'
else
render :edit
end
end
# DELETE /profiles/1
def destroy
@profile.destroy
redirect_to profiles_url, notice: 'Profile was successfully destroyed.'
end
private
# Use callbacks to share common setup or constraints between actions.
def set_profile
@profile = Profile.find(params[:id])
end
# Only allow a trusted parameter "white list" through.
def profile_params
params.require(:profile).permit(:first_name, :last_name, :gender, :birth_date, :school, :street_name, :zip_code, :city, :state, :country, :graduates_school_in)
end
end