-
-
Save omarqureshi/384400 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Controller | |
class Program < ActiveRecord::Base | |
STATUSES = %w(pending live on_hold completed) | |
KINDS = %w(social_video youtube facebook twitter) | |
has_one :flight, :dependent => :destroy | |
has_one :creative, :dependent => :destroy | |
accepts_nested_attributes_for :flight | |
accepts_nested_attributes_for :creative | |
belongs_to :campaign | |
belongs_to :advertiser | |
validates_presence_of :advertiser_id | |
validates_presence_of :campaign_id | |
def new_flight_attributes=(flight_attributes) | |
flight_attributes.each do |attribute| | |
flight.build(attributes) | |
end | |
end | |
end | |
## Model | |
def create | |
#@program = Program.new | |
#@program.attributes = params[:program] | |
@program = Program.create(params[:program]) | |
@campaign = @program.campaign | |
@program.save ? redirect_to(edit_campaign_program_path(@campaign, @program)) : render(:action => :new) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment