Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update order without AJAX #93

Closed
advantgroup opened this issue Mar 18, 2015 · 1 comment
Closed

Update order without AJAX #93

advantgroup opened this issue Mar 18, 2015 · 1 comment

Comments

@advantgroup
Copy link

I'm ordering only a selection of a master list, and storing the selection and its position in a different model (i.e., Master and Copy, and I want Copy ordered).

The easiest way I've found to achieve this is to let ranked-model do the initial ordering (i.e., no AJAX, just the JQueryUI.sortable list in the form). It works perfectly for create, and I think it'd work okay for updating too if I can find a way to re-save the positions on update (again, without AJAX). And, to complicate things further, entries in the selection can be changed, effectively deleting one ordering integer from the initial order, because it's stored on a relationship table.

I've tried resetting the positions on update in the controller to no avail:

Master.copies.each { |copy| copy.update_attribute :position, 0 }

However, deleting the copies on update and resetting them like so achieves the desired result:

def update
  @master.copies.destroy_all
  if @copy.update_attributes(copy_params)
  ...
end

Any ideas how to achieve what I'm after? Perhaps its out of scope for this gem, which is a shame because otherwise it's perfect.

To ask the this question in the most basic form: how is the order created? Can it be replicated for update?

@brendon
Copy link
Owner

brendon commented Jun 4, 2024

Closing this due to age.

@brendon brendon closed this as completed Jun 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants