模板缺少rails

时间:2013-03-08 14:09:28

标签: ruby-on-rails

如何在轨道上的红宝石中解决此错误“模板丢失” 我的控制器是

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 个答案:

答案 0 :(得分:-1)

您的def方法名称需要与您的视图名称相匹配。

def index
end

必须是index.html.erb

def hello
end 

将是hello.html.erb

def world 
end 

将是world.html.erb

如果没有,你会得到一个丢失的模板,因为它正在寻找那个特定的名称。