railscast 중첩 된 폼에 대한 스레드가 있다는 것을 알고 있습니다. 링크가없는 add_fields는 불안정한 j에 대한 변경 때문에 더 이상 레일 4에서 제대로 작동하지 않습니다. 내 중첩 된 양식을 작동시키기 위해 내가 변경해야하는 것을 이해하고 알려주는 사람이 있습니까? "다시"하려고 미안 : complex form을하지만 그는 레일 3 미안 레일을 사용 4. 나는 다음과 같은 오류받을 수 있나요 :link_to_add_fields/눈에 잘 띄지 않는 javascript 레일 4
undefined method `link_to_function' for
_form.html.erb에서 :
<%= link_to_add_fields("Add a Contact", f, :contacts, :class => "btn btn-primary", :title => "Add a new Contact") %>
을
내 application_helper.rb
def link_to_add_fields(name, f, association, options = {})
new_object = f.object.class.reflect_on_association(association).klass.new
fields = f.fields_for(association, new_object, :child_index => "new_#{ association }", :onsubmit => "return $(this.)validate();") do |builder|
render(association.to_s.singularize + "_fields", :f => builder)
end
link_to_function(name, "add_fields(this, \"#{ association }\", \"#{ escape_javascript(fields) }\")", options)
끝 끝
일 anks!
감사. 나는이 시도했지만 오류 (정의되지 않은 메서드 ...) 여전히 나타나고 ... 전체 줄을 밖으로 걸릴 경우 양식이 될 것 같아 보여주고있다. 레일 3.2.9에서 전혀 문제없이 작동합니다 ... – oliver