adding code climate, removing duplication

This commit is contained in:
Tyrel Souza 2014-04-25 11:37:17 -04:00
parent ac02238d62
commit f3e58009ef
2 changed files with 9 additions and 9 deletions

View File

@ -2,4 +2,4 @@ Vidpush
======= =======
[![Build Status](https://circleci.com/gh/propelmarketing/vidpush.png?circle-token=46474007c0807cf4b467fb96d7736422b2fa58a7)](https://circleci.com/gh/propelmarketing/vidpush) [![Build Status](https://circleci.com/gh/propelmarketing/vidpush.png?circle-token=46474007c0807cf4b467fb96d7736422b2fa58a7)](https://circleci.com/gh/propelmarketing/vidpush)
[![Code Climate](https://codeclimate.com/repos/535a76efe30ba01da902dc6b/badges/f1bfeadbed33f25ef547/gpa.png)](https://codeclimate.com/repos/535a76efe30ba01da902dc6b/feed)

View File

@ -33,10 +33,7 @@ class CampaignsController < ApplicationController
format.html { redirect_to campaign_path(@campaign.listingcode), notice: 'Campaign was successfully created.' } format.html { redirect_to campaign_path(@campaign.listingcode), notice: 'Campaign was successfully created.' }
end end
else else
respond_to do |format| show_errors('new')
format.json { render json: {error: @campaign.errors.full_messages } }
format.html { render action: 'new' }
end
end end
end end
@ -44,10 +41,7 @@ class CampaignsController < ApplicationController
if @campaign.update(campaign_params) if @campaign.update(campaign_params)
redirect_to campaign_path(@campaign.listingcode), notice: 'Campaign was successfully updated.' redirect_to campaign_path(@campaign.listingcode), notice: 'Campaign was successfully updated.'
else else
respond_to do |format| show_errors('edit')
format.json { render json: {error: @campaign.errors.full_messages } }
format.html { render action: 'edit' }
end
end end
end end
@ -57,6 +51,12 @@ class CampaignsController < ApplicationController
end end
private private
def show_errors(where_to)
respond_to do |format|
format.json { render json: {error: @campaign.errors.full_messages } }
format.html { render action: where_to }
end
end
def set_campaign def set_campaign
@campaign = set_by_options(:campaign, :listingcode) @campaign = set_by_options(:campaign, :listingcode)
end end