2014-04-07 18:41:34 +00:00
|
|
|
class CampaignsController < ApplicationController
|
|
|
|
before_action :set_campaign, only: [:show, :edit, :update, :destroy]
|
|
|
|
|
|
|
|
# GET /campaigns
|
|
|
|
def index
|
|
|
|
@campaigns = Campaign.all
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /campaigns/1
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /campaigns/new
|
|
|
|
def new
|
|
|
|
@campaign = Campaign.new
|
2014-04-07 21:24:08 +00:00
|
|
|
@campaign.videolistings.build
|
2014-04-07 18:41:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# GET /campaigns/1/edit
|
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
# POST /campaigns
|
|
|
|
def create
|
|
|
|
@campaign = Campaign.new(campaign_params)
|
|
|
|
|
|
|
|
if @campaign.save
|
|
|
|
redirect_to @campaign, notice: 'Campaign was successfully created.'
|
|
|
|
else
|
|
|
|
render action: 'new'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# PATCH/PUT /campaigns/1
|
|
|
|
def update
|
|
|
|
if @campaign.update(campaign_params)
|
|
|
|
redirect_to @campaign, notice: 'Campaign was successfully updated.'
|
|
|
|
else
|
|
|
|
render action: 'edit'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# DELETE /campaigns/1
|
|
|
|
def destroy
|
|
|
|
@campaign.destroy
|
|
|
|
redirect_to campaigns_url, notice: 'Campaign was successfully destroyed.'
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
|
|
def set_campaign
|
|
|
|
@campaign = Campaign.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
# Only allow a trusted parameter "white list" through.
|
|
|
|
def campaign_params
|
2014-04-07 21:24:08 +00:00
|
|
|
params.require(:campaign).permit(:clientid, :listingcode, :billingcode, :advertisername, :address1, :address2, :city, :state, :zip, :emailaddress, :customerfirstname, :customerlastname, :salesrep, :salesrepemail, :businessphone, :contactphone, :websiteurl,
|
|
|
|
videolistings_attributes: [:videocode, :producttypeid, :remoteassetsarchive, :voiceoverselection, :musicselection, :clientprovidedscript, :keywords, :focus, :notes, :asseturls,])
|
2014-04-07 18:41:34 +00:00
|
|
|
end
|
|
|
|
end
|