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

Associations do not provide attribute writers #45

Closed liveh2o closed 7 years ago

liveh2o commented 8 years ago

For some reason, defining an association (i.e. belongs_to) only defines an attribute reader. It should also provide an attribute writer.

fergmastaflex commented 7 years ago

It would seem perform_association only defines reader methods with no arguments.

I'm working on an addition that will also create writer methods as needed.

liveh2o commented 7 years ago

Nice. It would be really helpful to be able to set the instance variable to avoid unnecessary lookups.

fergmastaflex commented 7 years ago

Two question though:

1.) Should we have similar functionality with has_one?

2.) Should a remote object that doesn't exist be created if assigned using a writer method?

liveh2o commented 7 years ago

I would think all association methods would get setters: belongs_to, has_one, has_many.

I'd say we should shy away from automatically creating associated records for now to limit the scope. We can make that future functionality.