Created
March 8, 2010 01:05
-
-
Save recursive/324762 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
| 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