second attempt to fix the has one name collision issue

This commit is contained in:
Shishir Kakaraddi 2018-04-26 22:01:32 -07:00
parent 901801fa80
commit c943683141

View File

@ -9,10 +9,10 @@ if defined?(::ActiveRecord)
super super
name = reflection.name name = reflection.name
mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1 mixin.class_eval <<-CODE, __FILE__, __LINE__ + 1
unless defined? #{name}_id def #{name}_id
def #{name}_id # if an attribute is already defined with this methods name we should just use it
association(:#{name}).reader.try(:id) return read_attribute(__method__) if has_attribute?(__method__)
end association(:#{name}).reader.try(:id)
end end
CODE CODE
end end