我有以下块,它接受两个值(示例金额,但通常不止一个)。
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
当我提交记录时,这个块会遍历我相信的不同值,然后我假设看起来会输出这些值。问题是我收到以下错误:
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".
谁能告诉我为什么会这样,以及我如何生成显示这两条记录的视图。谢谢!