2013-03-08 116 views
-3

如何解決這個錯誤紅寶石「模板丟失」鐵路 我控制器模板丟失軌

class SayController < ApplicationController 
    def hello 
    @title = "Ruby on Rails" 
    @website = "www.9lessons.info" 
    end 
end 

我的HTML頁面

<html> 
    <head> 
    <title><%= @title %></title> 
    </head> 
    <body> 
    <h1>Welcome to <%= @website %></h1> 
    Addition : <%= 100 + 300 %> 
    </body> 
</html> 
+1

你能複製確切的錯誤嗎?並說明您嘗試訪問的網址是什麼? – jvnill 2013-03-08 14:10:32

回答

0

您的高清方法的名稱需要匹配您的視圖名稱。

def index 
end 

必須index.html.erb

def hello 
end 

將hello.html.erb

def world 
end 

將world.html.erb

如果沒有,你會得到一個缺失的模板因爲它正在尋找那個特定的名字。