###Rubyのリダイレクトについて
redairect_toというメソッドを実行してる最中にエラーが出てしまいます。
###発生している問題・エラーメッセージ
end def other redirect_to action: :index, params: {"msg": "from other page"} end end エラーメッセージ:ActionController::UrlGenerationError (No route matches {:action=>"index", :controller=>"tikka"}): app/controllers/tikka_controller.rb:13:in `other' エラーメッセージ2:NameError (undefined local variable or method `nill' for #<TikkaController:0x000000072d0418>):
###該当のソースコード
class TikkaController < ApplicationController def index if params["msg"] != nill then @title = params["msg"] else @title = "index" end @msg ="this is redirect sample..." end def other redirect_to action: :index, params: {"msg": "from other page"} end end routes.rbの全文(indexを追加) Rails.application.routes.draw do get "tikka/index" get "tikka", to: "tikka#index" get "tikka/other" end
###試したこと
routes.rbの修正。
Rails.application.routes.draw do
get "tikka/other"
end
###補足情報(言語/FW/ツール等のバージョンなど)
Ruby Rails
回答1件
あなたの回答
tips
プレビュー