liveh2o / active_remote

Active Remote provides Active Record-like object-relational mapping over RPC. It's Active Record for your platform.
MIT License
63 stars 23 forks source link

Updated for Rails 6.1 and Rails 7. #89

Closed skunkworker closed 2 years ago

skunkworker commented 2 years ago

It looks like (at least in Rails 7) that attributes need to be called with strings and not keys. Also calling subject.errors[:base] << "Boom!" looks like it's deprecated in favor of subject.errors.add(:base, :foo, message: "Boom!")

skunkworker commented 2 years ago
DEPRECATION WARNING: Calling `<<` to an ActiveModel::Errors message array in order to add an error is deprecated. Please call `ActiveModel::Errors#add` instead.

https://api.rubyonrails.org/v6.1.3/classes/ActiveModel/Errors.html#method-i-add

WriterZephos commented 2 years ago

My stab at this (only for rails 6.1) is here: https://github.com/liveh2o/active_remote/pull/86

I would prefer to find a solution that doesn't rely so much on private methods and logic, personally.

skunkworker commented 2 years ago

My stab at this (only for rails 6.1) is here: #86

I would prefer to find a solution that doesn't rely so much on private methods and logic, personally.

Well all it's doing is @attributes.write_from_user(attr_name, value) But #86 is missing the error changes

WriterZephos commented 2 years ago

Well all it's doing is @attributes.write_from_user(attr_name, value) But #86 is missing the error changes

Tests pass for 6.1 without those changes. I think updating incrementally is usually a good idea so that's what I was trying to do. Could always extract the changes for Rails 7 into a different PR.

film42 commented 2 years ago

Sounds like we're ready to release this change to add rails 7 support? I know people are asking about it.

skunkworker commented 2 years ago

Sounds like we're ready to release this change to add rails 7 support? I know people are asking about it.

I'll come back around to this soon and review it.

skunkworker commented 2 years ago

@WriterZephos I pulled in your changes into this branch from https://github.com/liveh2o/active_remote/pull/86