【问题标题】:Weird Missing Partial error in rails轨道中的奇怪缺失部分错误
【发布时间】:2013-01-25 16:03:41
【问题描述】:

您好,我的 rails 应用程序出现奇怪错误。

ActionView::MissingTemplate (Missing partial foo/bar, application/bar with {:locale=>[:en], :formats=>[:js, "application/ecmascript", "application/x-ecmascript", :html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :handlers=>[:erb, :builder, :coffee]}. Searched in: blah blah
):
  app/controllers/foo_controller.rb:9:in `doSomething'

现在我非常确定 app/views/foo 中有 bar.html.erb 文件。有任何想法吗?我听说当文件名中可能有空格时有时会发生这种情况,但事实并非如此。有什么想法吗?

【问题讨论】:

  • 您能否添加引发错误的代码,这样我们就不必猜测了? ;)
  • 当你使用render "bar"调用partial时,在foo目录里面必须有_bar.html.erb,你能给我看看foo_controller的代码吗

标签: ruby-on-rails partials


【解决方案1】:

app/views/foo bar.html.erb 中应为_bar.html.erb,因为所有部分名称都应以"_" 开头

【讨论】:

    【解决方案2】:

    部分名称以“_”下划线开头。看起来你在前缀 bar.html.erb 中错过了下划线

    【讨论】:

    • 你是救世主。我认为只有在没有特别给出名称作为渲染参数的情况下才使用下划线作为前缀。谢谢一百万
    猜你喜欢
    • 2012-06-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多