Skip to content

Commit

Permalink
[#447] The fix for #447 broke has_many :through associations
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanlarsen committed Dec 10, 2009
1 parent 7d84feb commit 4fbe02f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions hobo/lib/hobo/accessible_associations.rb
Expand Up @@ -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
Expand Down

0 comments on commit 4fbe02f

Please sign in to comment.