clowne-rb / clowne

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

Fix: Sequel adapter fail when clone a model without any association. #44

Closed tuanmai closed 5 years ago

tuanmai commented 5 years ago

Summary

I was trying to use clowne with sequel. One of my models doesn't have any association. And when I tried to clone that model, I encountered this error:

NoMethodError:
       undefined method `to_model' for nil:NilClass
       Did you mean?  to_yaml
     # ./lib/clowne/adapters/sequel/operation.rb:27:in `to_record'
     # ./lib/clowne/utils/operation.rb:69:in `persist'

You can reproduce it by the integration test I wrote.

To fix that, I wrapped the cloned record before finding it in the @records

ssnickolay commented 5 years ago

@tuanmai thanks for your time!