Skip to content

Instantly share code, notes, and snippets.

@recursive
Created March 8, 2010 01:05
Show Gist options
  • Select an option

  • Save recursive/324762 to your computer and use it in GitHub Desktop.

Select an option

Save recursive/324762 to your computer and use it in GitHub Desktop.
def create
@custom_errors = Array.new
@chain = current_user.chain
@chain.advertisers.each { |advertiser|
@deal = Deal.new(params[:deal])
@deal.advertiser_id = advertiser.id
@deal.advertiser.ripper = false
@deal.advertiser.category_id = advertiser.category.parent_id
@deal.advertiser.category_parent_id = advertiser.category.parent_id
if @deal.save
stuff such as nothing
else
@custom_errors << advertiser.id
end
}
if(request.post? && @custom_errors.empty?)
if @chain.admin_approved == true
flash[:notice] = "Deal Created Successfully"
else
flash[:notice] = 'Deal Created Successfully but...' +
'<span style="font-size:80%"><br />' +
'We still need to approve your account before the deal will be seen by consumers.<br />
It should not take us any longer than 30 minutes.</span>'
end
redirect_to :controller => "chain_deals"
else
@custom_errors.each do |error_id| {
errors.add_to_base("deal for advertiser with id: #{error_id} not created")
}
render :action => "new"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment