Sha256: a52606f230cf02f0116bf6d071af0932c9ec2dc566560b4c39822aa6a11220ee

Contents?: true

Size: 1.74 KB

Versions: 5

Compression:

Stored size: 1.74 KB

Contents

require_dependency "phcmemberspro/application_controller"

module Phcmemberspro
	class Members::MainsController < ApplicationController

		# Security & Action Filters
		before_action :require_user
		layout :phcmemberspro_membersmain_layouts_resolver
		before_action :set_members_main, only: [:show, :edit, :update, :destroy]

		# Member Profile List
		def index
			@members_mains = Members::Main.where(user_id: current_user.id)
		end

		# Detailed Member Profile
		def show
		end

		# New Member Profile
		def new
			@members_main = Members::Main.new
		end

		# Edit Member Profile
		def edit
		end

		# Create Member Profile Action
		def create
			@members_main = Members::Main.new(members_main_params)
			@members_main.user_id = current_user.id
			if @members_main.save
				redirect_to members_mains_path, notice: 'Member profile has been successfully created.'
				else
					render :new
			end
		end

		# Update Member Profile Action
		def update
			if @members_main.update(members_main_params)
				redirect_to members_mains_path, notice: 'Member profile has been successfully updated.'
				else
					render :edit
			end
		end

		# Delete Member Profile Action
		def destroy
			@members_main.destroy
			redirect_to members_mains_path, notice: 'Member profile and all businesses was successfully destroyed.'
		end

		private

		# Grab User Session Key (For ID)
		def current_user
			@_current_user ||= AuthRocket::Session.from_token(session[:ar_token]).try(:user)
		end

		# Common Callbacks
		def set_members_main
			@members_main = Members::Main.find(params[:id])
		end

		# White List
		def members_main_params
			params.require(:members_main).permit(:mfirstname, :mlastname, :mtitle, :memail, :mphone, :mnotes, :smfacebook, :smtwitter, :smlinkedin, :user_id)
		end

	end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
phcmemberspro-5.4.2 app/controllers/phcmemberspro/members/mains_controller.rb
phcmemberspro-5.4.1 app/controllers/phcmemberspro/members/mains_controller.rb
phcmemberspro-5.4.0 app/controllers/phcmemberspro/members/mains_controller.rb
phcmemberspro-5.3.10 app/controllers/phcmemberspro/members/mains_controller.rb
phcmemberspro-5.3.9 app/controllers/phcmemberspro/members/mains_controller.rb