Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/61.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 是否可以传递像';这样的局部变量:本地人=>;{:f=>;f}';使用RJ?_Ruby On Rails_Forms_Ruby On Rails 3_Rjs_Local Variables - Fatal编程技术网

Ruby on rails 是否可以传递像';这样的局部变量:本地人=>;{:f=>;f}';使用RJ?

Ruby on rails 是否可以传递像';这样的局部变量:本地人=>;{:f=>;f}';使用RJ?,ruby-on-rails,forms,ruby-on-rails-3,rjs,local-variables,Ruby On Rails,Forms,Ruby On Rails 3,Rjs,Local Variables,在我的“ROOT_RAILS/views/accounts/new.html.erb”中 <% form_for(@account, :remote => true, :url => accounts_path) do |f| %> <div class="new_account_form"> ... </div> <% end %> 但我有一个错误: undefined local va

在我的“ROOT_RAILS/views/accounts/new.html.erb”中

<% form_for(@account, :remote => true, :url => accounts_path) do |f| %>
    <div class="new_account_form">       
        ...
    </div>
<% end %>
但我有一个错误:

undefined local variable or method `f' for <<Class:0x00000...>>
未定义的局部变量或方法“f”
当然,在“ROOT\u RAILS/views/accounts/\u ew\u account\u partial.html.erb”中,我有如下内容:

...
<%= f.label :password %>
...
。。。
...

是否可以使用RJS传递诸如:locals=>{:f=>f}之类的局部变量?如果可以,如何传递?

呃。。。您的RJ没有可用的f,因为它是从控制器调用的。如果你能管理的话,整个表单应该在部分中。

嗯。。。您的RJ没有可用的f,因为它是从控制器调用的。如果您可以管理的话,整个表单应该在部分表单中。

对!我没想到,对!我没有想到。
...
<%= f.label :password %>
...