change routes to use clientid
add json files add jsonbuilder
This commit is contained in:
parent
3410022799
commit
c6d2a47b2a
2
Gemfile
2
Gemfile
@ -20,7 +20,7 @@ gem 'uglifier'
|
||||
gem 'unicorn'
|
||||
gem 'foundation-rails'
|
||||
gem 'devise'
|
||||
|
||||
gem 'jbuilder'
|
||||
|
||||
group :development do
|
||||
gem 'foreman'
|
||||
|
@ -94,6 +94,9 @@ GEM
|
||||
high_voltage (2.1.0)
|
||||
hike (1.2.3)
|
||||
i18n (0.6.9)
|
||||
jbuilder (2.0.6)
|
||||
activesupport (>= 3.0.0, < 5)
|
||||
multi_json (~> 1.2)
|
||||
jquery-rails (3.1.0)
|
||||
railties (>= 3.0, < 5.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
@ -230,6 +233,7 @@ DEPENDENCIES
|
||||
foreman
|
||||
foundation-rails
|
||||
high_voltage
|
||||
jbuilder
|
||||
jquery-rails
|
||||
launchy
|
||||
newrelic_rpm (>= 3.7.3)
|
||||
|
@ -13,7 +13,7 @@ class CampaignsController < ApplicationController
|
||||
# GET /campaigns/new
|
||||
def new
|
||||
@campaign = Campaign.new
|
||||
@campaign.videolistings
|
||||
@campaign.videolistings.build
|
||||
end
|
||||
|
||||
# GET /campaigns/1/edit
|
||||
@ -22,9 +22,7 @@ class CampaignsController < ApplicationController
|
||||
|
||||
# POST /campaigns
|
||||
def create
|
||||
clientid = campaign_params.delete(:clientid)
|
||||
@campaign = Campaign.find_or_create_by(clientid: clientid)
|
||||
@campaign.update(campaign_params)
|
||||
@campaign = Campaign.new campaign_params
|
||||
|
||||
if @campaign.save
|
||||
respond_to do |format|
|
||||
@ -54,7 +52,7 @@ class CampaignsController < ApplicationController
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_campaign
|
||||
@campaign = Campaign.find(params[:id])
|
||||
@campaign = Campaign.find_by_clientid(params[:clientid]) || not_found
|
||||
end
|
||||
|
||||
# Only allow a trusted parameter "white list" through.
|
||||
@ -67,4 +65,8 @@ class CampaignsController < ApplicationController
|
||||
:musicselection, :clientprovidedscript, :keywords, :focus, :notes, :asseturls,])
|
||||
end
|
||||
|
||||
|
||||
def not_found
|
||||
raise ActionController::RoutingError.new("Not Found by clientid")
|
||||
end
|
||||
end
|
||||
|
19
app/views/campaigns/show.json.jbuilder
Normal file
19
app/views/campaigns/show.json.jbuilder
Normal file
@ -0,0 +1,19 @@
|
||||
json.campaigns @campaigns do |campaign|
|
||||
json.clientid campaign.clientid
|
||||
json.listingcode campaign.listingcode
|
||||
json.billingcode campaign.billingcode
|
||||
json.advertisername campaign.advertisername
|
||||
json.address1 campaign.address1
|
||||
json.address2 campaign.address2
|
||||
json.city campaign.city
|
||||
json.state campaign.state
|
||||
json.zip campaign.zip
|
||||
json.emailaddress campaign.emailaddress
|
||||
json.customerfirstname campaign.customerfirstname
|
||||
json.customerlastname campaign.customerlastname
|
||||
json.salesrep campaign.salesrep
|
||||
json.salesrepemail campaign.salesrepemail
|
||||
json.businessphone campaign.businessphone
|
||||
json.contactphone campaign.contactphone
|
||||
json.websiteurl campaign.websiteurl
|
||||
end
|
@ -3,6 +3,6 @@ Vidpush::Application.routes.draw do
|
||||
devise_for :users
|
||||
root to: "campaigns#index"
|
||||
|
||||
resources :campaigns
|
||||
|
||||
resources :campaigns, param: :clientid
|
||||
resources :videolistings, param: :videocode
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user