clowne-rb / clowne

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

Association couldn't be found, Rails 4.1.8 #40

Closed vanboom closed 4 years ago

vanboom commented 5 years ago

I have a very simple two model scenario with a has_many association in the model that I want to clone. So I declared

class PostsCloner < Clowne::Cloner
  adapter :active_record
  include_association :comments
end

The clone attempt results in an exception: Clowne::Adapters::ActiveRecord::Resolvers::UnknownAssociation: Association comments couldn't be found for User

It appears that this code is attempting to resolve the relation using a string index into ...reflections, but the reflections hash uses symbols.

https://github.com/clowne-rb/clowne/blob/3d8f23f4aa39b33cefc73d18ef08fd13c0c742e9/lib/clowne/adapters/active_record/resolvers/association.rb#L12-L18

Maybe this is a compatibility issue with Rails 4.1.8, Ruby 2.3

vanboom commented 5 years ago

PR #41 submitted to address this

ssnickolay commented 4 years ago

Closed because of https://github.com/clowne-rb/clowne/pull/41#issuecomment-549055168

vanboom commented 3 years ago

Having the same issue on Rails 5.2.4.5 -- will dig further to see if I can improve the PR.