diff --git a/hobo/lib/hobo/accessible_associations.rb b/hobo/lib/hobo/accessible_associations.rb index df6e4bb02..6bbad6ae2 100644 --- a/hobo/lib/hobo/accessible_associations.rb +++ b/hobo/lib/hobo/accessible_associations.rb @@ -46,8 +46,11 @@ def find_or_create_and_update(owner, association_name, finder, record_hash_or_st # work around # https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3510-has_many-build-does-not-set-reverse-reflection # https://hobo.lighthouseapp.com/projects/8324/tickets/447-validation-problems-with-has_many-accessible-true - method = "#{owner.class.reverse_reflection(association_name).name}=".to_sym - record.send(method, owner) if record.respond_to? method + reverse = owner.class.reverse_reflection(association_name) + if reverse && reverse.macro==:belongs_to + method = "#{reverse.name}=".to_sym + record.send(method, owner) if record.respond_to? method + end else owner.include_in_save(association_name, record) end