ruby-hyperloop / hyper-mesh

The project has moved to Hyperstack!! - Synchronization of active record models across multiple clients using Pusher, ActionCable, or Polling
https://hyperstack.org/
MIT License
22 stars 12 forks source link

fix `Collection#set_belongs_to` to work with has_many through #83

Open catmando opened 6 years ago

catmando commented 6 years ago

probably means complete refactor of has_many_through.

What has_many_through should probably be doing is something like this:

Consider TodoItems.has_many :commenters, class: User, through: :comments

todo_item.commenters.first => todo_item.comments.first.user

In other words it asks just like a scope on Comment, but with the special property that the user (belongs_to) method is automatically applied.

probably its much easier to do this via some delegation class on top of the Comment all scope rather than all the complex mechanism currently.

Right now Collection#set_belongs_to is failing on most recent edge because of the removal of the method_missing which was allowing a bogus assignment to work. For now this has been patched up so it at least works for existing code.