문제

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