redirect_to "ページ先"
これだけで好きなページへ遷移させることができます。
指定方法は以下。
URLで指定
xxx_controller.rb
redirect_to "http://www.manbow.com"
prefixで指定
xxx_controller.rb
redirect_to root_path
アクションで指定
xxx_controller.rb
redirect_to action: :new
指定したコントローラーのアクションで指定
xxx_controller.rb
redirect_to controller: :users, action: :show
個別のリソースを指定
xxx_controller.rb
redirect_to controller: :users, action: :show, id: 1
前のページを指定
xxx_controller.rb
redirect_to :back
僕は基本prefixを使っています。
ではまた!