From b52a71e7c9f564fe5efc9b12d1e10ef0df70e396 Mon Sep 17 00:00:00 2001
From: Tyrel Souza
Date: Tue, 22 Apr 2014 11:02:40 -0400
Subject: [PATCH] Change clientid param to listingcode param
---
app/controllers/campaigns_controller.rb | 19 +++++++------------
app/models/campaign.rb | 1 -
app/views/campaigns/index.html.erb | 6 +++---
app/views/campaigns/show.html.erb | 4 ++--
config/routes.rb | 2 +-
5 files changed, 13 insertions(+), 19 deletions(-)
diff --git a/app/controllers/campaigns_controller.rb b/app/controllers/campaigns_controller.rb
index 6aa8589..f03547c 100644
--- a/app/controllers/campaigns_controller.rb
+++ b/app/controllers/campaigns_controller.rb
@@ -17,7 +17,7 @@ class CampaignsController < ApplicationController
end
def edit
- @action = campaign_path(@campaign.clientid)
+ @action = campaign_path(@campaign.listingcode)
end
@@ -27,19 +27,19 @@ class CampaignsController < ApplicationController
if @campaign.save
respond_to do |format|
format.json { render json: @campaign }
- format.html { redirect_to campaign_path(@campaign.clientid), notice: 'Campaign was successfully created.' }
+ format.html { redirect_to campaign_path(@campaign.listingcode), notice: 'Campaign was successfully created.' }
end
else
respond_to do |format|
format.json { render json: {error: @campaign.errors.full_messages } }
- format.html { render action: 'new' }
+ format.html { render action: 'new' }
end
end
end
def update
if @campaign.update(campaign_params)
- redirect_to campaign_path(@campaign.clientid), notice: 'Campaign was successfully updated.'
+ redirect_to campaign_path(@campaign.listingcode), notice: 'Campaign was successfully updated.'
else
respond_to do |format|
format.json { render json: {error: @campaign.errors.full_messages } }
@@ -55,11 +55,11 @@ class CampaignsController < ApplicationController
private
def set_campaign
- clientid = params[:clientid].to_s.gsub(/\D/, '').to_i
+ listingcode = params[:listingcode]
if params[:campaign]
- @campaign = Campaign.find_by_clientid(params[:campaign][:clientid]) || not_found
+ @campaign = Campaign.find_by_listingcode(params[:campaign][:listingcode]) || not_found
else
- @campaign = Campaign.find_by_clientid(clientid) || not_found
+ @campaign = Campaign.find_by_listingcode(listingcode) || not_found
end
end
@@ -84,9 +84,4 @@ class CampaignsController < ApplicationController
@BETTER_VIDEO_API_KEY = ENV['BETTER_VIDEO_API_KEY']
@BETTER_VIDEO_API_KEY ||= "propel test key"
end
-
-
- def json_errors
-
- end
end
diff --git a/app/models/campaign.rb b/app/models/campaign.rb
index 63e367c..127fb19 100644
--- a/app/models/campaign.rb
+++ b/app/models/campaign.rb
@@ -14,5 +14,4 @@ class Campaign < ActiveRecord::Base
#TODO Make API Calls
end
-
end
diff --git a/app/views/campaigns/index.html.erb b/app/views/campaigns/index.html.erb
index 752c6ee..531faad 100644
--- a/app/views/campaigns/index.html.erb
+++ b/app/views/campaigns/index.html.erb
@@ -18,7 +18,7 @@
<% @campaigns.each do |campaign| %>
- <%= link_to campaign.clientid, campaign_path(campaign.clientid) %> |
+ <%= link_to campaign.listingcode, campaign_path(campaign.listingcode) %> |
<%= campaign.listingcode %> |
<%= campaign.billingcode %> |
<%= campaign.address %> |
@@ -26,8 +26,8 @@
<%= campaign.state %> |
<%= campaign.zip %> |
<%= campaign.processed? %> |
- <%= link_to 'Edit', edit_campaign_path(campaign.clientid) %> |
- <%= link_to 'Destroy', campaign_path(campaign.clientid), method: :delete, data: { confirm: 'Are you sure?' } %> |
+ <%= link_to 'Edit', edit_campaign_path(campaign.listingcode) %> |
+ <%= link_to 'Destroy', campaign_path(campaign.listingcode), method: :delete, data: { confirm: 'Are you sure?' } %> |
<% end %>
diff --git a/app/views/campaigns/show.html.erb b/app/views/campaigns/show.html.erb
index f5dc29f..7ab3681 100644
--- a/app/views/campaigns/show.html.erb
+++ b/app/views/campaigns/show.html.erb
@@ -1,4 +1,4 @@
-<%= link_to 'Edit', edit_campaign_path(@campaign.clientid) %> |
+<%= link_to 'Edit', edit_campaign_path(@campaign.listingcode) %> |
<%= link_to 'Back', campaigns_path %>
@@ -72,7 +72,7 @@
-
+
Contactphone:
<%= @campaign.contactphone %>
diff --git a/config/routes.rb b/config/routes.rb
index e320fca..1c9528e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -9,6 +9,6 @@ Vidpush::Application.routes.draw do
root to: "campaigns#index"
- resources :campaigns, param: :clientid
+ resources :campaigns, param: :listingcode
resources :videolistings, param: :videocode
end