elight / acts_as_commentable_with_threading

Similar to acts_as_commentable; however, utilizes awesome_nested_set to provide threaded comments
MIT License
672 stars 167 forks source link

Comments not being added to commentable #108

Closed marcguilera closed 7 years ago

marcguilera commented 7 years ago

Hi.

Created a user:

user = User.create(name: 'marc', email: 'msjdhuhfuhfuhf@djfjijfei.es', confirmed_at: Time.now, password: 'password', password_confirmation: 'password')

Created a post:

post = Post.create(title: 'title', body: 'body', user: user)

Created a comment for the post

cmt = Comment.build_from(post, user.id, 'hello')

Which returned this:

<Comment id: nil, commentable_id: 1, commentable_type: "Post", title: nil, body: "hello", subject: nil, user_id: 1, parent_id: nil, lft: nil, rgt: nil, created_at: nil, updated_at: nil>

What's weird is that the post comments array is empty:

post.comment_threads Comment Load (0.4ms) SELECT "comments".* FROM "comments" WHERE "comments"."commentable_id" = ? AND "comments"."commentable_type" = ? [["commentable_id", 1], ["commentable_type", "Post"]] => #<ActiveRecord::Associations::CollectionProxy []>

Shouldn't this return the array of comments, so containing one comment? Post is marked with acts_as_commentable.

For the record: rails -v = 5.02 ruby -v = 2.3.0 acts_as_commentable_with_threading => latest from master