2

我已經檢查了9個關於此主題的類似問題,其中沒有一個幫助過。所有的文件都在那裏。命名空間Route MissingTemplate Error

您可以在photo中看到,我在views/admin/access/index.hmtl.erb中有一個視圖模板,但我收到一條錯誤消息,說它不存在。 admin/settings/index也找不到。可能會發生什麼?

如果這是一個非常簡單的錯誤,請提前道歉。我會很感激這方面的幫助。

例外:

ActionView::MissingTemplate: 

    Missing template admin/settings/index, application/index with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder]} 


ActionView::MissingTemplate: 

    Missing template admin/access/index, application/index with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder]} 

設置控制器:

class Admin::SettingsController < ApplicationController 

    def index 

    end 

門禁控制器:

class Admin::AccessController < ApplicationController 

    def index 

    end 

途徑(儘管不應該的問題):

namespace :admin do 
    resources :access, only: [:index, :update] 
    resources :settings, only: [:index, :update] 
    end 

回答

3

模板名稱應該是(擴展html.erb):

views/admin/access/index.html.erb 

但不是:

views/admin/access/index.hmtl.erb 
+1

沒錯。謝謝!雖然現在我覺得很愚蠢 – Onyooo