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

primary_key and dirty tracking #494

Open
zacharywelch opened this issue Apr 13, 2018 · 0 comments
Open

primary_key and dirty tracking #494

zacharywelch opened this issue Apr 13, 2018 · 0 comments

Comments

@zacharywelch
Copy link
Collaborator

Her doesn't setup dirty tracking on id or primary_key when a new model's initialized. This impacts the behavior of persisted? and new_record?

Existing behavior

class User
  include Her::Model
end

user = User.new(id: 5) #=> #<User(users/5) id=5>
user.new_record? #=> false
user.persisted? #=> true
user.changes #=> {}

Expected behavior

class User
  include Her::Model
end

user = User.new(id: 5) #=> #<User(users/5) id=5>
user.new_record? #=> true
user.persisted? #=> false
user.changes #=> {"id"=>[nil, 5]}

See #298 for more background.

We may need to track an instance variable of @new_record similar to AR

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

1 participant