我有以下块,它接受两个值(示例数量但通常多于一个)。
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".
任何人都可以建议为什么会这样,以及我如何生成一个显示这两个记录的视图。谢谢!