Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Problems with inverse #234

Open
tillsc opened this issue Dec 18, 2012 · 0 comments
Open

Problems with inverse #234

tillsc opened this issue Dec 18, 2012 · 0 comments

Comments

@tillsc
Copy link

tillsc commented Dec 18, 2012

The automatic detection of inverse relationships seems a little error-prone to me. It heavily depends upon the usage of symbols in :child_key Options. Example:

class A
  belongs_to :b
end

class B
  has n, :as, :child_key => 'b_id'
end

In this case the inverse would be generated (ignoring the existing one) because of :child_key being a String.

The Bug is located here:

self_key.send(operator, other_key)

 ["b_id"].send(:==, [:b_id]) # => false

This problem prevents the specification of DB constraints other then :protect (the default for automatically generated inverse relationships) when using Strings instead of Symbols in :child_key options.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant