LoginSignup
4
6

More than 5 years have passed since last update.

Rails Error `No template found for`

Posted at

No template found for AAController#BB

railsのcontrollerにて特定のメソッドを定義したにも関わらず、設定したアクションが行われないケースにおいて、terminalを覗くとこのような記述がある場合の解決法

BB.html.erbを作成

Rails 5 No template found errorより

Rails looks for a view file to render when a action is called, and it's looking for a file with the same name as the action.

Railsはアクションが呼ばれた際にそれに該当する同名のファイルを探すので、ファイルをview directoryに作成すれば解決するとのこと。

redirect_toの記述忘れ

僕の場合はこちらでした。
updateアクションを記述する際に

def update
    @cart = session[:cart].map { |item_id| Item.find(item_id) }
    @cart.delete(params[:id])
    redirect_to cart_index_path #ココ!
  end

メソッドを実行した際の戻り値?、帰るパスを設定し忘れていたので変化が発生せずにterminalにてエラーが出ていたようでした。

4
6
1

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
6