app/controllers/phcmembers/members/contacts_controller.rb in phcmembers-2.2.0 vs app/controllers/phcmembers/members/contacts_controller.rb in phcmembers-3.0.0
- old
+ new
@@ -2,41 +2,32 @@
module Phcmembers
class Members::ContactsController < ApplicationController
# Filters
- layout 'layouts/phcmembers/members/members_all.html.erb'
- before_filter :authenticate_user!, if: -> { defined?(Devise) }
+ before_action :set_paper_trail_whodunnit
+ before_action :phc_member_mains_info
before_action :set_members_contact, only: [:show, :edit, :update, :destroy]
+ # layout 'layouts/phcmemberspro/members/members_all.html.erb'
- # Add Member Contact Information
- before_action :phc_member_mains_info
-
- def phc_member_mains_info
- @members_main = Members::Main.find(params[:main_id])
- end
-
# Member Contact Index
def index
main = Members::Main.find(params[:main_id])
- @members_contact = main.contacts
+ @members_contacts = main.contacts.order('mcprovince ASC')
end
# Detailed Member Contact Information
def show
+ @versions = PaperTrail::Version.where(item_id: params[:id], item_type: 'Phcmembers::Members::Contact')
main = Members::Main.find(params[:main_id])
@members_contact = main.contacts.find(params[:id])
end
# New Contact
def new
main = Members::Main.find(params[:main_id])
@members_contact = main.contacts.build
- respond_to do |format|
- format.html # new.html.erb
- format.xml { render :xml => @members_contact }
- end
end
# Edit Contact
def edit
main = Members::Main.find(params[:main_id])
@@ -46,11 +37,11 @@
# Create Action
def create
@main = Members::Main.find(params[:main_id])
@members_contact = @main.contacts.create(members_contact_params)
if @members_contact.save
- redirect_to members_main_contacts_path, notice: 'Member contact information was successfully created.'
+ redirect_to members_main_contacts_path, notice: 'Member contact was successfully created.'
else
render :new
end
end
@@ -66,22 +57,27 @@
# Delete Action
def destroy
@main = Members::Main.find(params[:main_id])
@members_contact = @main.contacts.find(params[:id])
@members_contact.destroy
- redirect_to members_main_contacts_path, notice: 'Member contact information was successfully destroyed.'
+ redirect_to members_main_contacts_path, notice: 'Member contact was successfully destroyed.'
end
private
+ # Get Main Member Info
+ def phc_member_mains_info
+ @members_main = Members::Main.find(params[:main_id])
+ end
+
# Common Callbacks
def set_members_contact
@members_contact = Members::Contact.find(params[:id])
end
# White List
def members_contact_params
- params.require(:members_contact).permit(:mccontactname, :mccompanyname, :mcaddressl1, :mcaddressl2, :mccity, :mcprovince, :mccountry, :mcpostalcode, :mcphone, :mcwebsite, :mcemail, :main_id)
+ params.require(:members_contact).permit(:mcaddressl1, :mcaddressl2, :mccity, :mcprovince, :mccountry, :mcpostalcode, :mctype, :main_id)
end
end
end