我尝试更新祖先gem中的parent_id,但返回nil.Send parent_id与ajax更新动作但保存nil.Categories系统的工作原理,点击输入更改parent_id然后打开模态,选择一个类别,关闭模态然后保存类别为但是当点击更新时保存为零。我该如何解决?
ajax代码
$.ajax
type: 'GET'
data: {parent_id: this.id}
categories_controller.rb
def update
@category.parent_id = params[:parent_id]
@category.update_attributes(category_params)
end
_category.haml
%input.radio_category{:id => "#{category.id}", :name => "radio", :type => "radio", :value => "#{category.name}", remote: true, 'data-parent-id': category.id}>
= category.name
- if category.has_children?
= render partial: "category", locals: { collection: category.children }
提前致谢!