0

I have the following block which takes in two values (example amount but generally more than one).

def new
# Called when campaign is approved, respond then displays table with campaign details, which when submitted is passed to create
  @campaign = Campaign.find(params[:campaign_id])
  @campaign.each do |value|
    @applied_campaign = AppliedCampaign.new(:campaign_id => value.id, :start_date => value.start_date||Time.now, :end_date =>  value.end_date, :active => true)    
    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: value }
    end
  end   
end

When i submit the records this block iterates through the different values I believe and then I assume looks to output these values. The problem is that I am getting the following error:

Render and/or redirect were called multiple times in this action. Please note that you may 
only call render OR redirect, and at most once per action. Also note that neither redirect 
nor render terminate execution of the action, so if you want to exit an action after 
redirecting, you need to do something like "redirect_to(...) and return".

Can anyone advise why this is the case and how I could generate a view with these two records displayed. Thanks!

EamonnMcElroy
  • 587
  • 6
  • 20

0 Answers0