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 'with_same' if attribute nil #141

Closed
ilyario opened this issue Mar 21, 2019 · 3 comments
Closed

update 'with_same' if attribute nil #141

ilyario opened this issue Mar 21, 2019 · 3 comments

Comments

@ilyario
Copy link

ilyario commented Mar 21, 2019

class Task < ApplicationRecord
  include RankedModel
  ranks :row_order, with_same: :parent_id
end

I'm use with_same and my model has parent_id equal to nil.
And I have problem use '@task.update_attribute :row_order_position, new_position' if parent_id

@task.row_order 
=> -8379763 

project.tasks.where(parent_id: nil).rank(:row_order).pluck(:id, :row_order)
=>  [[43988, -8379763], [38997, -8378203], [39019, -8314748]]

@task.update_attribute :row_order_position, 1
=> UPDATE "tasks" SET "updated_at" = $1, "row_order" = $2 WHERE "tasks"."id" = $3  [["updated_at", "2019-03-21 11:27:17.220547"], ["row_order", -8382364], ["id", 43988]]

project.tasks.where(parent_id: nil).rank(:row_order).pluck(:id, :row_order)
=> [[43988, -8382364], [38997, -8378203], [39019, -8314748]]

but

If use alias :last it's works

@ilyario
Copy link
Author

ilyario commented Mar 21, 2019

Rails 5.2.2.1
ruby 2.5.3p105

@brendon
Copy link
Owner

brendon commented Mar 21, 2019

Hi @ilyario, thanks for getting in touch with this issue. Do you think you'd be able to create a PR with a failing test case for this one?

@brendon
Copy link
Owner

brendon commented Jun 4, 2024

No failing test or communication was received, so closing.

@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