Skip to main content

Nested Comment Threads in Rails - Part 1 Discussion

General • Asked by Chris Oliver

Fallback

Greate episode! If I should get this episode a couple of years ago, that may should saved my life jajaja!

So, this is the same logic you are using here in your post and epdisode comments?

Fallback

Yep, pretty much.

Fallback

Awesome! Thanks for sharing Chris!


Fallback

Woohoo, thanks for doing this!


Fallback

Thanks Chris! . This is great!


Fallback

For some reason...you often create episodes just fitting in my current needs..thanks.


Fallback

Chris as part of the next part2 series, please add the ability to dynamically update without refreshing the page.... Best practice. As i am able to use the reply system, but i hate how the page has to refresh and i have been struggling to have it appear directly on the page without refreshing... That will be helpful!!

Fallback

any help on this topic will be helpful

Fallback

I can cover that in a follow-up episode. 👍


Fallback

Thank you chris for the consideration!!! that why i re-joined:) when you cather to all your user needs, you build a loyal group of people... Thank i am looking forward for the episode... you know when that will be? :) excited!!!


Fallback

hi chris,

using the rails generate command below:
rails g model Comment user:references commentable:references{ploymorphic}:index parent_id:integer body:text

created the migration file:
class CreateComments < ActiveRecord::Migration[5.2]
def change
create_table :comments do |t|
t.references :user, foreign_key: true
t.references :commentable, ploymorphic: true, foreign_key: true
t.integer :parent_id
t.text :body

  t.timestamps
end

end
end

which failed " PG::UndefinedTable: ERROR: relation "commentables" does not exist "

i went through the github files and found that your migration file did not have the foreign_key: true on the commentable line. i reran the migration and it worked, but just out of curiosity why did the references create a foreign_key: true for my migration and not your migration.

cheers

gus

Fallback

It looks like you spelled polymorphic wrong which might be why it threw that error.

Fallback

bugger! typing on the train LOL! thanks


Fallback

chris can we also cover auto scrolling when comment meets at end of page, if it has more comments that it will load as user scrolls? maybe on the main page or do it on a pop up when a user clocks view more comments it pops up and then they can see all the comments and as they reach bottom if there is more comment it scrolls?


Fallback

Chris for some reason, i can't get stimulus Reply effect to work.... I am able to hide the reply but clicking on it does not do anything .. it does not expand or collapse

This seems to work for me "visibility: hidden" instead of d-none

but when i click reply, that does not work. i stimulus js dont seem to work for me. any debugging tips?

Fallback

I'd just throw some console.logs into your JS and see what's getting called and what's not. Then you can figure out what you are missing.


Fallback

Hi Chris, would it be worth using the Ancestry gem for nested comments like this?
I've been questioning whether there would be any noticable benefits. Thanks for this!

Fallback

Yep, you certainly could. If you need those features it'd be great. Otherwise, there's not a whole lot of difference.


Login or create an account to join the conversation.