adding code climate, removing duplication
This commit is contained in:
parent
ac02238d62
commit
f3e58009ef
@ -2,4 +2,4 @@ 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)
|
||||
|
@ -33,10 +33,7 @@ class CampaignsController < ApplicationController
|
||||
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' }
|
||||
end
|
||||
show_errors('new')
|
||||
end
|
||||
end
|
||||
|
||||
@ -44,10 +41,7 @@ class CampaignsController < ApplicationController
|
||||
if @campaign.update(campaign_params)
|
||||
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 } }
|
||||
format.html { render action: 'edit' }
|
||||
end
|
||||
show_errors('edit')
|
||||
end
|
||||
end
|
||||
|
||||
@ -57,6 +51,12 @@ class CampaignsController < ApplicationController
|
||||
end
|
||||
|
||||
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
|
||||
@campaign = set_by_options(:campaign, :listingcode)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user