1

在我的 'ROOT_RAILS/views/accounts/new.html.erb' 我有

<% form_for(@account, :remote => true, :url => accounts_path) do |f| %>
    <div class="new_account_form">       
        ...
    </div>
<% end %>

我正在尝试在“ROOT_RAILS/views/accounts/create.js.rjs”中使用 RJS 来替换这样的 html

page.replace_html :new_account_form, :partial => "/users/accounts/new_account_partial", :locals => { :f => f }

但我收到一个错误:

undefined local variable or method `f' for <<Class:0x00000...>>

当然在 'ROOT_RAILS/views/accounts/_ew_account_partial.html.erb' 我有这样的东西:

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

是否可以使用 RJS 传递局部变量,例如 ':locals => { :f => f }'?如果是这样,怎么做?

4

1 回答 1

1

呃......你的 rjs 没有 f 可用,因为它是从控制器调用的。如果您可以管理它,整个表格应该是部分的。

于 2011-01-13T12:25:42.873 回答