Note that there are some explanatory texts on larger screens.

plurals
  1. POundefined method `capture_haml' for #<#<Class:0xbe53d68>:0xcf9cb24> in rails
    text
    copied!<p>I am working on deleting a branch of a company using <code>rails ajax</code>. </p> <p>Simple form for company account is - </p> <pre><code>= simple_form_for @company_account, :remote =&gt; true, :url =&gt; company_account_path, :method =&gt; :put do |f| </code></pre> <p>using this form i am creating, updating and deleting regions and branches of regions.</p> <pre><code>%div{ :id =&gt; 'branches_' + r.id.to_s}= render 'branches',f: f, r: region, company_account: @company_account </code></pre> <p>relation between company, region and branch is:</p> <pre><code>company has_many: regions region belong_to: company regions has_many: branches branches belongs_to: regions </code></pre> <p>In this form i have a partial for displaying regions and branches, which uses form object of company account <code>f</code>. All this is working fine. I'm able to create new regions branches. Now i'm trying to delete branch using <code>ajax</code>.</p> <p>When this call goes to controller i'm creating a form object for company account to render a partial like - <strong>In my controller</strong></p> <pre><code>@f = view_context.simple_form_for @company_account, :remote =&gt; true, :url =&gt; company_account_path, :method =&gt; :put do |f| render_to_string(:partial =&gt; 'company_accounts/branches', :locals =&gt; {f: f, r: @region, company_account: @company_account }).html_safe end </code></pre> <p>and passing this @f object in responce using javascript as - </p> <pre><code>$('#branches_' + &lt;%= @region.id%&gt;).html('&lt;%= escape_javascript @f %&gt;'); $('#branches_' + &lt;%= @region.id%&gt;).show(); </code></pre> <p>But unfortunately in response i am getting error - </p> <pre><code>undefined method `capture_haml' for #&lt;#&lt;Class:0xbe53d68&gt;:0xcf9cb24&gt; </code></pre> <p>Don't know what i am missing. Can any one please help??</p> <p>Thanks in advance.</p> <p><strong>Update:</strong></p> <p>This is the Backtrace: </p> <pre><code>ActionView::Template::Error (undefined method `capture_haml' for #&lt;#&lt;Class:0xb9db2a4&gt;:0xc953560&gt;): 1: #inactive_branches 2: = f.simple_fields_for :regions, r do |reg| 3: %table.preferenceDetails 4: %tr 5: %td app/views/company_accounts/_inactive_branches.html.haml:2:in `_app_views_company_accounts__inactive_branches_html_haml___356774371_104988750' app/controllers/company_accounts_controller.rb:129:in `block in branches' app/controllers/company_accounts_controller.rb:122:in `branches' </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload