【问题标题】:Missing template error even though template exists即使模板存在,也缺少模板错误
【发布时间】:2012-05-19 05:04:12
【问题描述】:

我正在查看日志,这就是我所看到的

Processing by TestController#get_branches_for_repo as */*

ActionView::MissingTemplate (Missing template test/get_branches_for_repo, application/get_branches_for_repo with {:handlers=>[:erb, :builder], :formats=>[:html, :text, :js, :css, :ics, :csv, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json], :locale=>[:en, :en]}. Searched in:* "/export/web/metrics-vviswanathan/app/views"):

我有意见

_get_branches_for_repo.erb

在应用程序/视图/测试/中

处理为*/*是什么意思?

哦,我的控制器功能是这样的

def get_branches_for_repo
   blah

   render :partial => "get_branches_for_repo"
end

请帮忙

【问题讨论】:

    标签: ruby-on-rails


    【解决方案1】:

    为什么你的_get_branches_for_repo.erb 文件名中间没有.html?添加它,重新保存文件以防万一,然后重试。

    关于*/*。我知道页面刷新后的 IE 会这样做。这不是 Rails 的事情。你不必担心它。

    【讨论】:

      【解决方案2】:

      渲染局部时是否使用特定布局?我通常在我的视图中使用部分,因为它们需要成为某些模板的一部分,我不相信它们可以在那里自己呈现。通过将视图文件从 _get_branches_for_repo.erb 更改为 get_branches_for_repo.erb(无下划线)并在控制器中一起取出渲染语句,您能否获得相同的效果。这样,您将使用模板而不是部分模板。如果您提供更多信息,我也许可以提供更多帮助。我希望这有帮助。这是一个对我有很大帮助的渲染指南http://guides.rubyonrails.org/layouts_and_rendering.html

      【讨论】:

        猜你喜欢
        • 2016-02-25
        • 1970-01-01
        • 2015-09-08
        • 1970-01-01
        • 2017-08-28
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多