Change clientid param to listingcode param

This commit is contained in:
Tyrel Souza 2014-04-22 11:02:40 -04:00
parent 754576a440
commit b52a71e7c9
5 changed files with 13 additions and 19 deletions

View File

@ -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

View File

@ -14,5 +14,4 @@ class Campaign < ActiveRecord::Base
#TODO Make API Calls
end
end

View File

@ -18,7 +18,7 @@
<tbody>
<% @campaigns.each do |campaign| %>
<tr>
<td><%= link_to campaign.clientid, campaign_path(campaign.clientid) %></td>
<td><%= link_to campaign.listingcode, campaign_path(campaign.listingcode) %></td>
<td><%= campaign.listingcode %></td>
<td><%= campaign.billingcode %></td>
<td><%= campaign.address %></td>
@ -26,8 +26,8 @@
<td><%= campaign.state %></td>
<td><%= campaign.zip %></td>
<td><%= campaign.processed? %></td>
<td><%= link_to 'Edit', edit_campaign_path(campaign.clientid) %></td>
<td><%= link_to 'Destroy', campaign_path(campaign.clientid), method: :delete, data: { confirm: 'Are you sure?' } %></td>
<td><%= link_to 'Edit', edit_campaign_path(campaign.listingcode) %></td>
<td><%= link_to 'Destroy', campaign_path(campaign.listingcode), method: :delete, data: { confirm: 'Are you sure?' } %></td>
</tr>
<% end %>
</tbody>

View File

@ -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 %>
<div class="col-md-2"></div>
@ -72,7 +72,7 @@
</p>
<p>
<p>
<strong>Contactphone:</strong>
<%= @campaign.contactphone %>
</p>

View File

@ -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