2017-01-07 8 views
1

をredirect_toを使用するには:レール:私は私のルートファイルで定義されている次のルートを持っているか、正しく

constraints(subdomain: "abc") do 
    get "/action" => "abc#init" 
    get "/action/:d" => "abc#action" 
end 

私はinit行動からそのようにリダイレクトすることができますことを想定:

redirect_to action_path(d: "12345") 

しかし、ことサーバーが無限にinitアクションにリダイレクトされると、ブラウザエラーが発生します。

これを実行するにはどうすればよいでしょうか?

+0

あなたのルートに名前を付ける必要がありますか? –

+0

@AlexanderLunaは、 'init'という名前の公共コントローラの共通アクションです:) – jonhue

答えて

2

あなたは初期化アクションで何を意味するのです

constraints(subdomain: "abc") do 
    get "/action" => "abc#init", as: :init_action 
    get "/action/:d" => "abc#action", as: :d_action # something fancier maybe 
end 

redirect_to d_action_path(d: 'something') 
関連する問題