-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
ActiveModel::Model Support #40
Comments
This looks like a clean solution. Will consider getting this into the library soon. Thanks. |
I'm extending the feature I built with this and I believe there's an edge case when an Active Record class is a child of an Active Model object. This proposal doesn't cover and I'm not sure how to extend it to make it work. class Journey
include ActiveModel::Model
attribute :itinerary # active record object goes here
end
# schema: [name]
class Itinerary < ApplicationRecord
end
journey = Journey.new
journey.itinerary = Itinerary.new(name: "Hello World")
journey.itinerary.name # => "Hello World"
payload = URI::UID.build(journey, { include_changes: true }).payload
decoded_journey = URI::UID.from_payload(payload).decode
decoded_journey.itinerary.name # => nil I tried using Any ideas? |
I also tried registering the settings like so: UniversalID::Settings.register :changed, { prepack: { include_blank: false}, database: { include_changes: true, include_descendants: true, descendant_depth: 2} } This didn't work either. I've traced it down to this line:
For some reason, it's not understanding that I want to include changes. |
Hey! I've managed to add ActiveModel::Model support like so:
With this, a class including ActiveModel that responds to
attributes
now works.I wonder if this is the right way to do it though. What do you think @hopsoft ?
The text was updated successfully, but these errors were encountered: