Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails rails中奇怪的缺失部分错误_Ruby On Rails_Partials - Fatal编程技术网

Ruby on rails rails中奇怪的缺失部分错误

Ruby on rails rails中奇怪的缺失部分错误,ruby-on-rails,partials,Ruby On Rails,Partials,你好,我的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,

你好,我的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文件。有什么想法吗?我听说当文件名中可能有空格时,有时会发生这种情况,但事实并非如此。有什么想法吗?

部分名称以“u”下划线开头。看起来您在
app/views/foo-bar.html.erb中的前缀bar.html.erb中缺少下划线。erb
应该是
\u-bar.html.erb
,因为所有的部分名称都应该以
“\ucode>

开头。您能添加引起错误的代码吗?这样我们就不必猜测错误了?;)当你使用render“bar”调用partial时,在foo目录中必须有_bar.html.erb,你能告诉我foo_控制器的代码吗?你是救世主。我认为下划线只是在没有特别指定名称作为要呈现的参数时才加上前缀。万分感谢