redirect_to "'http://qiita.com':リダイレクト先のURL", :status => :'moved_permanently:ステータスコード'
basic_controller.rb(res_redirectアクション)
# 外部サイトにリダイレクト(301 Moved Permanentlyでアドレス移転を通知)
redirect_to 'http://qiita.com', :status => :moved_permanently
# 同じコントローラないの異なるアクションにリダイレクト
redirect_to :action => 'render_text'
# articlesコントローラのindexアクションにリダイレクト
redirect_to :controller => 'articles', :action => 'index'
# リダイレクト先を自動生成されるURLヘルパーで指定
redirect_to article_path(1)
# 一つ前のページにリダイレクト
redirect_to :back
redirect_to('{ :action => 'redirect_flash2' }:リダイレクト先のURL',
:notice => 'noticeメッセージ:リダイレクト先に引き渡したいメッセージ')
}
redirect_to('{ :action => 'redirect_flash2' }:リダイレクト先のURL',
:flash => {':notice:パラメータ名' => 'noticeメッセージ:リダイレクト先に引き渡したいメッセージ' })
basic_controller.rb(redirect_flashアクション)
# redirect_flash2アクションにflashメッセージnoticeを引き渡す
redirect_to({ :action => 'redirect_flash2' },
:notice => 'noticeメッセージ')
# 以下のコードも同じ意味
redirect_to({ :action => 'redirect_flash2' },
:flash => {:notice => 'noticeメッセージ' })
basic/redirect_flash2.html.erb
<%# いずれも同じ意味(flash[...]の気泡は、notice、alert以外で利用) %>
<p><%= notice %></p>
<p><%= flash[:notice] %></p>