clowne-rb / clowne

A flexible gem for cloning models
https://clowne.evilmartians.io
MIT License
316 stars 18 forks source link

Plans to support belongs to and has many through? #20

Closed matthewford closed 5 years ago

matthewford commented 5 years ago

Hello,

Thanks for the gem are there any plans to support belongs to or has_many through associations?

daniel-rikowski commented 5 years ago

I just hacked together an implementation for belongs_to:

https://gist.github.com/daniel-rikowski/790e07db36a00925f653714f9c66f20c

Caution: It was rather easy, so it's quite possible I missed something important.

Usage: include_belongs_to :author

If you need has_many through you can just clone the through association (the one without the through option). Unfortunately you have to save and reload the model in order to update the parent association (the one with the through option)