Module: TheSortableTreeController::ExpandNode
Instance Method Summary
collapse
#the_define_common_variables
Instance Method Details
#expand_node ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/the_sortable_tree_controller.rb', line 20
def expand_node
id = params[:id].to_i
return render(nothing: true) unless id
sort = (params[:tree_sort] == 'reversed') ? 'reversed_' : nil
variable, collection, klass = self.the_define_common_variables
variable = self.instance_variable_set(variable, klass.find(id))
@children = variable.children.send("#{sort}nested_set")
return render(nothing: :true) if @children.count.zero?
render layout: false, template: "#{collection}/expand_node"
end
|