Skip to content

Conversation

vsmay98
Copy link
Contributor

@vsmay98 vsmay98 commented Jan 23, 2022

Fix: #64

This fix will support after_change callback for unique_list

class Person < ApplicationRecord
  kredis_list :names, after_change: ->(p) {  }
  kredis_unique_list :skills, limit: 2, after_change: :skillset_changed

  def skillset_changed
    puts 'skillset_changed'
  end
end
Loading development environment (Rails 7.0.0)
3.0.0 :001 > Person.last.skills << 'rails'
  Person Load (0.2ms)  SELECT "persons".* FROM "persons" ORDER BY "persons"."id" DESC LIMIT ?  [["LIMIT", 1]]
  Kredis Proxy (0.0ms)  LREM persons:2:skills [0, "rails"]
  Kredis Proxy (0.0ms)  RPUSH persons:2:skills ["rails"]
  Kredis Proxy (0.0ms)  LTRIM persons:2:skills [-5, -1]
skillset_changed
 => [0, 2, "OK"]

@vsmay98
Copy link
Contributor Author

vsmay98 commented Jan 30, 2022

Hello @julianrubisch @dhh,
Could you please review this PR?

@dhh dhh merged commit cb647e8 into rails:main Jan 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

after_change callback not working for unique_list
3 participants