Louis | Adds agencies

This commit is contained in:
Loos
2014-09-21 18:23:15 -05:00
parent 36e7c1624f
commit 7ed3fce648
14 changed files with 180 additions and 3 deletions
+57
View File
@@ -0,0 +1,57 @@
class AgenciesController < ApplicationController
before_action :set_agency, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
def index
@agencies = Agency.all
end
def show
end
def new
@agency = Agency.new
end
def edit
end
def create
@agency = Agency.new(agency_params)
if @agency.save
redirect_to @agency, notice: 'Agency was successfully created.'
else
render action: 'new'
end
end
def update
if @agency.update(agency_params)
redirect_to @agency, notice: 'Agency was successfully updated.'
else
render action: 'edit'
end
end
def destroy
@agency.destroy
redirect_to clients_url
end
private
def set_agency
@agency = Agency.find(params[:id])
end
def agency_params
params.require(:agency).permit(
:agency_name,
:contact_name,
:street_address,
:city,
:state,
:postal_code,
:phone_number,
:email)
end
end