2011-01-13 30 views
1

在我的 'ROOT_RAILS /视图/帐号/ new.html.erb' 我有是否可以使用RJS来传递局部变量,如':locals => {:f => f}'?

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

,我试图在 'ROOT_RAILS /视图/帐号/ create.js.rjs' 来代替HTML中使用RJS这样

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

,但我得到一个错误:

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

当然,在 'ROOT_RAILS /视图/帐号/ _ew_account_partial.html.erb' 我有这样的事情:

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

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

回答

1

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

+0

对!我没有想到这一点。 – user502052

相关问题