Skip to content

Conversation

@seanpdoyle
Copy link
Contributor

@seanpdoyle seanpdoyle commented Oct 24, 2025

By including the ActiveModel::AttributeAssignment, the Base class
can access the assign_attributes method for bulk assignment of
attributes without saving them to the server (like through
Base#update_attributes).

Person.schema = { name: "string" }

person = Person.new
person.id   # => nil
person.name # => nil

person.assign_attributes id: 1, name: "Matz"
person.id   # => 1
person.name # => "Matz"

@seanpdoyle seanpdoyle force-pushed the attribute-assignment branch 4 times, most recently from 97b1bc5 to c163899 Compare October 24, 2025 19:12
By including the [ActiveModel::AttributeAssignment][], the `Base` class
can access the [assign_attributes][] method for bulk assignment of
attributes **without** saving them to the server (like through
`Base#update_attributes`).

```ruby
Person.schema = { name: "string" }

person = Person.new
person.id   # => nil
person.name # => nil

person.assign_attributes id: 1, name: "Matz"
person.id   # => 1
person.name # => "Matz"
```
[ActiveModel::AttributeAssignment]: https://edgeapi.rubyonrails.org/classes/ActiveModel/AttributeAssignment.html
[assign_attributes]: https://edgeapi.rubyonrails.org/classes/ActiveModel/AttributeAssignment.html#method-i-assign_attributes
@seanpdoyle seanpdoyle force-pushed the attribute-assignment branch from c163899 to 2244311 Compare October 27, 2025 21:12
@seanpdoyle
Copy link
Contributor Author

After more consideration, I think the similarities that the between assign_attributes and load have the potential for confusion. I'm closing this PR in favor of #410, since that explores fully integrating with Active Model attributes.

@seanpdoyle seanpdoyle closed this Oct 27, 2025
@seanpdoyle seanpdoyle deleted the attribute-assignment branch October 27, 2025 21:52
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

Successfully merging this pull request may close these issues.

1 participant