def confirm_invite_new_tutor
redirect_with_msg = false
@game_school = GameSchool.find(params[:id])
existing_user_emails = params[:all_emails][:existing_user] || []
new_users = params[:param_game_school][:game_school_invites_attributes]
if existing_user_emails.present?
existing_user_emails.each do |existing_user|
// some code
end
redirect_with_msg = true
end
if new_users.present?
if @game_school.update_attributes(params[:param_game_school])
redirect_with_msg = true
else
render :invite_tutor_form
end
end
if redirect_with_msg
redirect_to @game_school, notice: "daw"
else
redirect_to @game_school
end
end
リターンでレンダリングします。レンダリングまたはリダイレクトを呼び出すことができるのは1回の操作につき1回だけです。また、リダイレクトもレンダリングもアクションの実行を終了させないので、リダイレクト後にアクションを終了するには、 "redirect_to(...)and return"のような処理が必要です。Redirect_toと私はこれを実行していた場合、私は</p> <p>は、レンダリングおよび/またはこのアクション内で複数回呼び出されたリダイレクトなどのエラーを取得しています
私はリターンを使用している場合は、他のページに移動し、フラッシュmsgも表示されません。 これを修正するには?
`redirect_to @game_school and return`
の下にこれがあなたのためにあなたがコントローラでrender
またはredirect
を使用
何についてredirect_to xyz &&返信? – Lee
'と'と '&&'(lol)は、Rubyにおいて、優先順位に関して2つの非常に異なる意味を持っています(http://ruby-doc.org/core-2.3.0/doc/syntax/precedence_rdoc.html参照)。この場合、 'と'を使うべきです。これは、トピックに関するもう1つの興味深い資料です。http://devblog.avdi.org/2014/08/26/how-to-use-rubys-english-and-operator-with-going-nuts/ – lucke84