diff --git a/README.md b/README.md index 2262f25..5302497 100644 --- a/README.md +++ b/README.md @@ -2,3 +2,4 @@ Vidpush ======= [![Build Status](https://circleci.com/gh/propelmarketing/vidpush.png?circle-token=46474007c0807cf4b467fb96d7736422b2fa58a7)](https://circleci.com/gh/propelmarketing/vidpush) + diff --git a/app/controllers/campaigns_controller.rb b/app/controllers/campaigns_controller.rb index fae2a03..6aa8589 100644 --- a/app/controllers/campaigns_controller.rb +++ b/app/controllers/campaigns_controller.rb @@ -30,7 +30,10 @@ class CampaignsController < ApplicationController format.html { redirect_to campaign_path(@campaign.clientid), notice: 'Campaign was successfully created.' } end else - render action: 'new' + respond_to do |format| + format.json { render json: {error: @campaign.errors.full_messages } } + format.html { render action: 'new' } + end end end @@ -38,7 +41,10 @@ class CampaignsController < ApplicationController if @campaign.update(campaign_params) redirect_to campaign_path(@campaign.clientid), notice: 'Campaign was successfully updated.' else - render action: 'edit' + respond_to do |format| + format.json { render json: {error: @campaign.errors.full_messages } } + format.html { render action: 'edit' } + end end end @@ -63,6 +69,7 @@ class CampaignsController < ApplicationController :customerfirstname, :customerlastname, :description, :emailaddress, :facebookurl, :listingcode, :productsandservices, :state, :targetaudience, :tollfreephone, :vpa, :websiteurl, :zip, + videolistings_attributes: [:id, :asseturls, :clientprovidedscript, :focus, :keywords, :musicselection, :notes, :producttypeid, :videocode, :voiceoverselection, @@ -77,4 +84,9 @@ 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