I create a hierarchical category in Rails using Ancestry, and I allow the user to select the parent of the object they create. I show existing categories using the drop down menu:
<%= f.input :ancestry, collection: Category.sorted_list %>
As long as the user selects an existing node, all is well. If the user selects empty from the drop-down list, I expect Ancestry to create a root node, but instead the form throws an "invalid" error.
My controller does nothing:
def update @category = Category.find(params[:id]) respond_to do |format| if @category.update_attributes(params[:category]) format.html { redirect_to @category, notice: 'Category was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @category.errors, status: :unprocessable_entity } end end end
I'm new to Rails, so I'm not sure how to attack this issue. Is there a configuration for Ancestry that I missed, or is it a form validator that might be overly secure?
source share