app/controllers/phcmemberspro/members/contacts_controller.rb in phcmemberspro-5.4.2 vs app/controllers/phcmemberspro/members/contacts_controller.rb in phcmemberspro-6.0.0

- old
+ new

@@ -12,11 +12,11 @@ before_action :phc_member_mains_info # Member Contact Index def index main = Members::Main.find(params[:main_id]) - @members_contacts = main.contacts.where(user_id: current_user.id).order('mcprovince ASC') + @members_contacts = main.contacts.where(membership_id: membership_info.id).order('mcprovince ASC') end # Detailed Member Contact Information def show main = Members::Main.find(params[:main_id]) @@ -41,20 +41,25 @@ # Create Action def create @main = Members::Main.find(params[:main_id]) @members_contact.user_id = current_user.id + @members_contact.membership_id = membership_info.id + @members_contact.oganization_id = membership_info.org_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.' else render :new end end # Update Action def update + @members_contact.user_id = current_user.id + @members_contact.membership_id = membership_info.id + @members_contact.oganization_id = membership_info.org_id if @members_contact.update(members_contact_params) redirect_to members_main_contacts_path, notice: 'Member contact information was successfully updated.' else render :edit end @@ -78,17 +83,22 @@ # Grab User Session Key (For ID) def current_user @_current_user ||= AuthRocket::Session.from_token(session[:ar_token]).try(:user) end + # Get Current User from Above and Get Membership Info + def membership_info + AuthRocket::Membership.all(user_id: current_user.id).first + 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(:mcaddressl1, :mcaddressl2, :mccity, :mcprovince, :mccountry, :mcpostalcode, :mctype, :main_id, :user_id) + params.require(:members_contact).permit(:mcaddressl1, :mcaddressl2, :mccity, :mcprovince, :mccountry, :mcpostalcode, :mctype, :main_id, :user_id, :membership_id, :oganization_id) end end end