为什么我缺少模板移动/家庭/索引,应用程序/索引?

时间:2012-04-16 18:29:44

标签: ruby-on-rails ruby

我正在学习Ruby,我设置了一个这样的控制器:

class Mobile::HomeController < ApplicationController
  def index

  end

  def create

  end

end

这是非常基本的,并添加了这样的路线:

 scope :module => :mobile, :as => :mobile do
    constraints(:subdomain => /m/) do
      resources :home
    end
  end

当我尝试在浏览器中看到该页面时,我收到此错误:

Missing template mobile/home/index, application/index with {:locale=>[:en, :en], :formats=>[:html], :handlers=>[:haml, :erb, :builder]}. Searched in: * "/Users/alexgenadinik/projects/cmply/cmply-app/app/views" * "/Library/Ruby/Gems/1.8/gems/ckeditor-3.6.3/app/views" * "/Library/Ruby/Gems/1.8/gems/kaminari-0.13.0/app/views" * "/Library/Ruby/Gems/1.8/gems/devise-2.0.4/app/views"

但我在这里有一个视图页面:

app/views/layouts/mobile/application.html.haml

我需要指定的问题是我在控制器中返回HAML格式吗?或者我做错了什么?

1 个答案:

答案 0 :(得分:2)

您的程序会尝试查找常规模板,而不是布局。尝试创建页面:

app/views/mobile/home/index.html.haml