Class: Phcmemberspro::Member::ProfilesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/phcmemberspro/member/profiles_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#current_user, #get_member_profile_info, #membership_info, #new_login_url, #require_user

Instance Method Details

#createObject

POST - Member Profile



36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/phcmemberspro/member/profiles_controller.rb', line 36

def create
	@member_profile = Member::Profile.new(member_profile_params)
	@member_profile.user_id = current_user.id
	@member_profile.membership_id = membership_info.id
	@member_profile.oganization_id = membership_info.org_id
	if @member_profile.save
		redirect_to member_profiles_url, notice: 'Profile was successfully created.'
		else
			render :new
	end
end

#destroyObject

DELETE - Member Profile



61
62
63
64
# File 'app/controllers/phcmemberspro/member/profiles_controller.rb', line 61

def destroy
	@member_profile.destroy
	redirect_to member_profiles_url, notice: 'Profile was successfully destroyed.'
end

#editObject

EDIT FORM - Member Profile



32
33
# File 'app/controllers/phcmemberspro/member/profiles_controller.rb', line 32

def edit
end

#indexObject

INDEX - Member Profile



16
17
18
# File 'app/controllers/phcmemberspro/member/profiles_controller.rb', line 16

def index
	@member_profiles = Member::Profile.where(oganization_id: membership_info.org_id)
end

#newObject

NEW FORM - Member Profile



27
28
29
# File 'app/controllers/phcmemberspro/member/profiles_controller.rb', line 27

def new
@member_profile = Member::Profile.new
end

#showObject

DETAILED PROFILE - Member Profile



21
22
23
24
# File 'app/controllers/phcmemberspro/member/profiles_controller.rb', line 21

def show
	@member_profile = Member::Profile.find(params[:id])
	@versions = PaperTrail::Version.where(item_id: params[:id], item_type: 'Phcmemberspro::Member::Profile')
end

#updateObject

PATCH/PUT - Member Profile



49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/phcmemberspro/member/profiles_controller.rb', line 49

def update
	@member_profile.user_id = current_user.id
	@member_profile.membership_id = membership_info.id
	@member_profile.oganization_id = membership_info.org_id
	if @member_profile.update(member_profile_params)
		redirect_to member_profiles_url, notice: 'Profile was successfully updated.'
		else
			render :edit
	end
end