私は2つの値を取る次のブロックを持っています(例の量ですが、通常は複数です)。
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".
なぜこれが当てはまるのか、これら2つのレコードが表示されたビューをどのように生成できるのか、誰にでもアドバイスできますか? ありがとう!