Re: [Rails] acts_as_commentable_with_threading

44 views
Skip to first unread message

Rob Biedenharn

unread,
Jun 26, 2017, 9:43:19 AM6/26/17
to rubyonra...@googlegroups.com
At this point, you should be able to look around a small codebase like this and figure it out, but here are the "hints":





If you don't get how this is working, point to a specific thing and ask a more directed question.

-Rob

P.S. The routes could easily be amended to be:
resources :comments, except: [:new]

On 2017-Jun-25, at 22:04 , fugee ohu <fuge...@gmail.com> wrote:

I'm looking at the Dustin Fisher example app on github https://github.com/DustinFisher/acts-as-commentable-with-threading-example/tree/master/ but his comments_controller.rb has no new action Can someone clarify please?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6554adbe-6847-4925-bbaa-097b583eda93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

fugee ohu

unread,
Jun 27, 2017, 11:59:49 PM6/27/17
to Ruby on Rails: Talk

Yes thanks, that's what I've been doing 

fugee ohu

unread,
Jun 28, 2017, 1:49:36 AM6/28/17
to Ruby on Rails: Talk


On Monday, June 26, 2017 at 9:43:19 AM UTC-4, Rob Biedenharn wrote:

Why does comments/_reply.html.erb have to recursively render itself again after the form ?

fugee ohu

unread,
Jun 28, 2017, 1:51:34 AM6/28/17
to Ruby on Rails: Talk


On Monday, June 26, 2017 at 9:43:19 AM UTC-4, Rob Biedenharn wrote:

I put a new action in the comments controller since you don't use a link to new you render the form instead

Rob Biedenharn

unread,
Jun 28, 2017, 10:06:35 AM6/28/17
to rubyonra...@googlegroups.com
Because you can reply to a comment and then someone could reply to your reply, etc. Note that the recursive call is only for the comment.children so it won't go on forever.
-Rob

Rob Biedenharn

unread,
Jun 28, 2017, 10:09:25 AM6/28/17
to rubyonra...@googlegroups.com
On 2017-Jun-28, at 01:51 , fugee ohu <fuge...@gmail.com> wrote:

On Monday, June 26, 2017 at 9:43:19 AM UTC-4, Rob Biedenharn wrote:
At this point, you should be able to look around a small codebase like this and figure it out, but here are the "hints":





If you don't get how this is working, point to a specific thing and ask a more directed question.

-Rob

P.S. The routes could easily be amended to be:
resources :comments, except: [:new]

On 2017-Jun-25, at 22:04 , fugee ohu <fuge...@gmail.com> wrote:

I'm looking at the Dustin Fisher example app on github https://github.com/DustinFisher/acts-as-commentable-with-threading-example/tree/master/ but his comments_controller.rb has no new action Can someone clarify please?

I put a new action in the comments controller since you don't use a link to new you render the form instead

Unless you're changing other parts, too. You will NEVER hit the :new action because you ALWAYS create the comment form in the context of a Post or another Comment. Like I said, you could add `, except: [:new]` to the route if it bothers you.
-Rob

fugee ohu

unread,
Jun 29, 2017, 10:59:42 AM6/29/17
to Ruby on Rails: Talk

 So in your example the forms already on the page in index view instead of a link to new comment? If yes whats wrong with a link to new comment instead of a text area and submit button already rendered?

Rob Biedenharn

unread,
Jun 29, 2017, 11:42:21 AM6/29/17
to rubyonra...@googlegroups.com
If you do that, you need to pass the "parent" object to the `new` action. There's nothing "wrong" with that. You probably need to define your own new_comment route if you want the URL to look nice and not have query parameters to define the parent object. (If you intend to eliminate threaded comments where the parent is another comment, you have just a little more work to do, but then you might not even need Comment to be polymorphic [if you can't comment on more than one kind of model].)

-Rob

Reply all
Reply to author
Forward
0 new messages