2
我正在使用rails ajax
刪除公司的一個分支。在軌中的#<#<Class:0xbe53d68>:0xcf9cb24>的未定義方法`capture_haml'
的公司帳戶進行簡單的形式是 -
= simple_form_for @company_account, :remote => true,
:url => company_account_path,
:method => :put do |f|
採用這種形式,我創建,更新和刪除區域和地區的分支機構。公司,區域和分支之間
%div{ :id => 'branches_' + r.id.to_s}= render 'branches',f: f, r: region, company_account: @company_account
關係是:
company has_many: regions
region belong_to: company
regions has_many: branches
branches belongs_to: regions
在這種形式中,我有一個部分,用於顯示區域和分支,其使用公司帳戶f
的形式的對象。所有這些工作正常。我可以創建新的區域分支。現在我試圖用ajax
刪除分支。
當此呼叫轉到控制器我創建的公司帳戶表單對象呈現部分像 - 在我的控制器
@f = view_context.simple_form_for @company_account, :remote => true,
:url => company_account_path,
:method => :put do |f|
render_to_string(:partial => 'company_accounts/branches', :locals => {f: f, r: @region, company_account: @company_account }).html_safe
end
,並使用JavaScript作爲通過這個@f對象的性反應 -
$('#branches_' + <%= @region.id%>).html('<%= escape_javascript @f %>');
$('#branches_' + <%= @region.id%>).show();
但不幸的是響應我收到錯誤 -
undefined method `capture_haml' for #<#<Class:0xbe53d68>:0xcf9cb24>
不知道我在想什麼。任何人都可以幫忙嗎?
在此先感謝。
更新:
這是回溯:
ActionView::Template::Error (undefined method `capture_haml' for #<#<Class:0xb9db2a4>:0xc953560>):
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'
回溯在這裏會有很大的幫助。如果你不調用'capture_haml',聽起來像你的助手之一,並且在不應該的情況下。 – Matchu
我做了所有的回溯,沒有運氣.. :( – User16119012
我認爲他意味着你應該發佈你得到的'undefined method'結果的回溯。 – aceofspades