Class: Phcmemberspro::Member::AddressesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/phcmemberspro/member/addresses_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 - Directory Listings



40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/phcmemberspro/member/addresses_controller.rb', line 40

def create
	@profile = Member::Profile.find(params[:profile_id])
	@member_address = @profile.addresses.create(member_address_params)
	@member_address.user_id = current_user.id
	@member_address.membership_id = membership_info.id
	@member_address.oganization_id = membership_info.org_id
	if @member_address.save
		redirect_to member_profile_addresses_url, notice: 'Listing was successfully created.'
		else
			render :new
	end
end

#destroyObject

DELETE - Directory Listings



66
67
68
69
70
71
# File 'app/controllers/phcmemberspro/member/addresses_controller.rb', line 66

def destroy
	@profile = Member::Profile.find(params[:profile_id])
	@member_address = @profile.addresses.find(params[:id])
	@member_address.destroy
	redirect_to member_profile_addresses_url, notice: 'Listing was successfully destroyed.'
end

#editObject

EDIT - Directory Listings



36
37
# File 'app/controllers/phcmemberspro/member/addresses_controller.rb', line 36

def edit
end

#indexObject

INDEX - Directory Listings



17
18
19
20
# File 'app/controllers/phcmemberspro/member/addresses_controller.rb', line 17

def index
	profile = Member::Profile.find(params[:profile_id])
	@member_addresses = profile.addresses.where(oganization_id: membership_info.org_id)
end

#newObject

NEW - Directory Listings



30
31
32
33
# File 'app/controllers/phcmemberspro/member/addresses_controller.rb', line 30

def new
	profile = Member::Profile.find(params[:profile_id])
	@member_address = profile.addresses.build
end

#showObject

LISTINGS DETAILS - Directory Listings



23
24
25
26
27
# File 'app/controllers/phcmemberspro/member/addresses_controller.rb', line 23

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

#updateObject

PATCH/PUT - Directory Listings



54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/phcmemberspro/member/addresses_controller.rb', line 54

def update
	@member_address.user_id = current_user.id
	@member_address.membership_id = membership_info.id
	@member_address.oganization_id = membership_info.org_id
	if @member_address.update(member_address_params)
		redirect_to member_profile_addresses_url, notice: 'Listing was successfully updated.'
		else
			render :edit
	end
end