LoginSignup
4
4

More than 3 years have passed since last update.

No template for interactive requestの対処法

Posted at

アプリ作成中にNo template for interactive requestが発生した。

エラー

私の場合は
No template for interactive request
PagesController#index is missing a template for request formats: text/html

であった。

routes.rb
Rails.application.routes.draw do
  resources :pages
  root 'pages#index'
end
pagescontroller
class PagesController < ApplicationController

  def index
  end
end

ビューファイルもしっかりapp/view/pagesにindex.html.hamlで作成していたので、原因がわからず解決できなかった。

原因

PagesController#index is missing a template for request formats: text/htmlとエラー文ではhtml文を呼んでいたが、自分はhamlファイルを生成してしまっていた。

解決法

ファイル名をindex.html.hamlからindex.html.erbに変更

これで解決する事ができた

hamlでのビューファイルを呼び出すために

投稿者はhamlを利用したかったが、hamlを使うには haml-railsというgemをインストールしなければならなかったらしい。 

gemfile
gem 'haml-rails'

これで、hamlファイルを呼び出す事ができた。

反省

この解決だけで1時間ほど時間を食ってしまったのが辛かったので、もっと速い間隔で試行錯誤を行うことを心がける。

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