Errors now show in JSON

This commit is contained in:
Tyrel Souza 2014-04-21 17:22:26 -04:00
parent d18e94817d
commit 754576a440
2 changed files with 15 additions and 2 deletions

View File

@ -2,3 +2,4 @@ Vidpush
=======
[![Build Status](https://circleci.com/gh/propelmarketing/vidpush.png?circle-token=46474007c0807cf4b467fb96d7736422b2fa58a7)](https://circleci.com/gh/propelmarketing/vidpush)

View File

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