ruby on rails - ActiveRecord order not working -


in controller, after reprioritizing "child", lists children in new order: @child.parent.children.sort_by{|g| g.priority }

this, surprisingly, doesn't work: @child.parent.children.order(priority: :asc)

why doesn't .order work? instead of sorting correctly, it's sorting previous order before operation run, assume it's using cached results (the query run before in operation). how 1 bust cache, if indeed problem? i've tried @child.reload after reprioritizing no avail.

if have ordering on children association might try use reorder apply new ordering:

@child.parent.children.reorder(priority: :asc) 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -