Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.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_Ruby On Rails 4_Haml_Partial - Fatal编程技术网

Ruby on rails 使用局部变量呈现局部的Rails

Ruby on rails 使用局部变量呈现局部的Rails,ruby-on-rails,ruby-on-rails-4,haml,partial,Ruby On Rails,Ruby On Rails 4,Haml,Partial,我需要一些关于我正在开发的测试应用程序的帮助。我在我的应用程序中多次重复这一行,所以我决定将其作为部分渲染。当我这样做时,我得到一个错误,说它没有看到局部变量。下面是正在发生的事情: = simple_form_for ([@user, @dogs]) do |b| = render 'dogs/dogs-cats-partials/newupload', :dog => b, :user => b 这是部分文件中的内容 .form-group.required

我需要一些关于我正在开发的测试应用程序的帮助。我在我的应用程序中多次重复这一行,所以我决定将其作为部分渲染。当我这样做时,我得到一个错误,说它没有看到局部变量。下面是正在发生的事情:

= simple_form_for ([@user, @dogs]) do |b| 
        = render 'dogs/dogs-cats-partials/newupload', :dog => b, :user => b
这是部分文件中的内容

.form-group.required
  = b.input :title, autofocus: true, :class => "form-control", :required => false
.form-group.required
  = b.input :description, autofocus: false, :class => "form-control", :required => false
下面是确切的错误:

undefined local variable or method `b' for #<#<Class:0x007f2ae1d8a5a0>:0x007f2ae1b4dc60>
未定义的局部变量或方法“b”#
提前感谢所有能够帮助您的人。。。在这个问题上纠缠了一个小时:)

“b”从未传递给部分用户。试试这个:


render'dogs/dogs-cats partials/newupload',b:b,dogs:@dogs,user:@user

确切的错误是什么?请在问题中发表。@pavan刚刚编辑。如果您只使用:渲染“dogs/dogs-cats partials/newupload”,则感谢您提供的提示。。。。因为您正在发送引用您的简单表单的局部变量“dog”和“user”。。。不知道背后的逻辑是什么哇。。。那是一个脸掌。。。非常感谢你的帮助!