- Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
I've been developing using the default value with proc in Kredis and encountered an issue.
However, I'm not sure if there's a misunderstanding in my use of the design.
app/models/user.rb class User < ApplicationRecord kredis_string :full_name, default: ->(u) { "#{u.first_name} #{u.last_name}" } end user1 = User.create(first_name: 'John', last_name: 'Doe') user2 = User.create(first_name: 'Tom', last_name: 'Smith')I expected it to work like this:
user1.full_name # => 'John Doe' user2.full_name # => 'Tom Smith' But what actually happens is:
user1.full_name # => 'John Doe' user2.full_name # => 'John Doe' The default proc for the user seems to retrieve the data of the first user record.
Upon further investigation, it seems related to this segment of the code:
kredis/lib/kredis/attributes.rb
Line 132 in 4fbb2f5
| when Proc then Proc.new { default.call(self) } |
May I ask if this is considered an issue?
danielncdanielnc
Metadata
Metadata
Assignees
Labels
No labels