Skip to content

collection << item returns incorrect collection.count #138

Closed
@barriehadfield

Description

@barriehadfield

In poly-assoc3 branch:

class ExerciseType < ApplicationRecord
  has_many :exercise_types_user
  has_many :users, through: :exercise_types_user
end

class User < ApplicationRecord
  has_many :exercise_types_user
  has_many :exercise_types, through: :exercise_types_user
end

class ExerciseTypesUser < ApplicationRecord
  belongs_to :user
  belongs_to :exercise_type
end

# works perfectly:
user.exercise_types << exercise_type

# but here is the bug..
exercise_types.users.count
# returns a number higher than count + 1
# fine after a page refresh, so its just the client count which is not being updated correctly

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions