LoginSignup
4
4

More than 5 years have passed since last update.

rails(4.1.0)でaction名がlocationとなっているものの中でredirect_toするとstack level too deepエラーが発生した。

Last updated at Posted at 2014-05-12

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 にアクセスした時の画面

スクリーンショット 2014-05-12 22.13.00.png

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4