سؤال

In my 'ROOT_RAILS/views/accounts/new.html.erb' I have

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

and I am trying to use RJS in 'ROOT_RAILS/views/accounts/create.js.rjs' to replace html like this

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

but I get an error:

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

Of course in 'ROOT_RAILS/views/accounts/_ew_account_partial.html.erb' I have something like this:

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

Is it possible to pass local variables like ':locals => { :f => f }' using RJS? If so, how?

هل كانت مفيدة؟

المحلول

Uh... your rjs doesn't have f available to it because it's called from the controller. The entire form ought to be in the partial, if you can manage it.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top