update models

This commit is contained in:
Tyrel Souza 2014-04-24 14:09:21 -04:00
parent 339a262e06
commit e63409d72a
3 changed files with 8 additions and 8 deletions

View File

@ -17,6 +17,9 @@ class CampaignsController < ApplicationController
end end
def edit def edit
if @campaign.processed
redirect_to campaign_path(@campaign.listingcode), notice: 'Campaign has been submitted, Cannot edit.'
end
@action = campaign_path(@campaign.listingcode) @action = campaign_path(@campaign.listingcode)
end end
@ -65,13 +68,13 @@ class CampaignsController < ApplicationController
def campaign_params def campaign_params
params.require(:campaign).permit(:id, :address, :advertisername, :awards, :background, :billingcode, params.require(:campaign).permit(:id, :address, :advertisername, :awards, :background, :billingcode,
:businessphone, :categories, :city, :clientid, :companycolors, :contactphone, :businessphone, :categories, :city, :companycolors, :contactphone,
:customerfirstname, :customerlastname, :description, :emailaddress, :facebookurl, :customerfirstname, :customerlastname, :description, :emailaddress, :facebookurl,
:listingcode, :productsandservices, :state, :targetaudience, :tollfreephone, :listingcode, :productsandservices, :state, :targetaudience, :tollfreephone,
:vpa, :websiteurl, :zip, :vpa, :websiteurl, :zip,
videolistings_attributes: [:_destroy, :id, :asseturls, :clientprovidedscript, :focus, videolistings_attributes: [:_destroy, :id, :asseturls, :clientprovidedscript, :focus,
:keywords, :musicselection, :notes, :producttypeid, :keywords, :musicselection, :notes,
:videocode, :voiceoverselection, :videocode, :voiceoverselection,
]) ])
end end

View File

@ -1,8 +1,6 @@
class Campaign < ActiveRecord::Base class Campaign < ActiveRecord::Base
has_many :videolistings, :dependent => :delete_all has_many :videolistings, :dependent => :delete_all
accepts_nested_attributes_for :videolistings,:reject_if => :all_blank, :allow_destroy => true accepts_nested_attributes_for :videolistings,:reject_if => :all_blank, :allow_destroy => true
validates :clientid, presence: true, uniqueness: true
validates :billingcode, uniqueness: true
validates :listingcode, presence: true, uniqueness: true validates :listingcode, presence: true, uniqueness: true
validates :advertisername, presence: true validates :advertisername, presence: true
validates :websiteurl, presence: true validates :websiteurl, presence: true
@ -14,8 +12,6 @@ class Campaign < ActiveRecord::Base
self.clientid = 720 self.clientid = 720
end end
after_create :send_to_better_video after_create :send_to_better_video
def send_to_better_video def send_to_better_video
#TODO Make API Calls #TODO Make API Calls

View File

@ -9,6 +9,7 @@ Vidpush::Application.routes.draw do
root to: "campaigns#index" root to: "campaigns#index"
resources :campaigns, param: :listingcode resources :campaigns, param: :listingcode do
resources :videolistings, param: :videocode resources :videolistings, param: :videocode
end end
end