locationだけではなくmessageでエラーが発生したいう人もいた。
RailsでSystemStackError: stack level too deepに遭遇した… - (define -ayalog '())
原因はコントローラーの継承元のApplicationControllerのどこかに既に定義しているのだろうとは思うが、見つけられなかった。
stack level too deepエラーが発生したらaction名を変更すればとりあえずリダイレクト処理が上手く行ったが、action名に指定してはいけない名前一覧みたいのをほしいと思った。
以下ソース
routes.rb
root 'hoge#index'
get 'location' => 'hoge#location'
get 'message' => 'hoge#message'
hoge_controller.rb
class HogeController < ApplicationController
def index
render :text => "index"
end
def location
redirect_to :root
end
def message
redirect_to :root
end
end
/location
にアクセスした時の画面