characters
のコレクションはfollowing
にあります。各character
にはユニークなハンドルがあります。私はデータベースがcharacter
とハンドルbarry1
の1つだけであることを確認しました。それはfalseを返すだRailsは理解できません.include?行動
following.include?(other_character) # false
、私はbarry1
がfollowing
であることを確信している:私はやろうとしています。 id
は違うと思いますが、barry1
は1つだけです。どうしたの?
character.rb
has_many :following, through: :active_follow_relationships, source: :followed
プット:
puts following.first.handle # barry1
puts other_character.handle # barry1
puts following.first # #<Character:0x007fef15231490>
puts other_character # #<Character:0x007fef09bb4d58>
puts following.first.id # 21
puts other_character.id # 8
を使用すると、以下のソリューションでそれを持っている[21]ではありませんother_character [8] – MZaragoza
オブジェクトが同じでない場合、インクルードは機能しません。ハンドルプロパティでインクルードをチェックする場合は、次のようにします。 {| f | f.handle == other_character.handle} –