All threads / Nested Comment Threads in Rails - Part 3 Discussion

Ask A Question

Notifications

You’re not receiving notifications from this thread.

Nested Comment Threads in Rails - Part 3 Discussion

Really great series, thank you for doing it. One question:
I have a comment form below the comments and it is not clearing out. However, when I move above the comments it does. Any thoughts?

Really great series, thank you for doing it. One question:

I have a comment form below the comments and it is not clearing out once the comment is posted. However, when I move the form above the comments (as shown in the tutorial) it does clear the form. Any thoughts?

Reply

Rails 5.2.1 comes with Content Security Policy DSL by default. Here we can specificy what is allowed to run. If we have something like

Rails.application.config.content_security_policy do |policy|
  policy.default_src :self, :https
  policy.connect_src :self
  #...
  policy.script_src  :self
end

# If you are using UJS then enable automatic nonce generation
Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }

in our CSP file I think this would disallow everything in create.js.erb ? We could add unsafe_eval to the policy but I believe this negates the whole purpose.

What can we add to allow the create.js.erb to be allowed by the Content Security Policy? I tried adding the <%= csp_meta_tag %> as recommeded here https://edgeguides.rubyonrails.org/security.html#content-security-policy and mentioned here https://github.com/rails/rails/pull/32018. Am I understanding the architecture correctly?

Reply

Hi Chris - great tutorial. Is this methodology what you would recommend if you are adding comments to a new site? I know there are gems out there that build this in automatically. Also, what about Vue.js - do you think using Ajax in this way is preferable to building out some Vue.js component.

Reply

Great tutorial.

Unfortunately, this breaks the max_nesting from the last episode :/

Reply

Hey Chris, just following up on Jake's comment. I'm also having the issue where max_nesting no longer works after implementing ajax following this video (the comments keep nesting past the max_nesting depth). Any idea what's causing this to break or how to fix it?

This series has been very helpful. Thanks so much!

Reply

Hey Chris, Adding Ajax breaks the max_nesting. Any idea how to fix it?

Reply

Hey Chris i followed everything and used the source code yet the comments wont load with the JS. I have other elements on the web application that render find with no refresh ajax and all. I don't understand why this isn't working.. Please let me know if you have any ideas!! Thank you very much I hope you're doing well during this time. Thank you.

Reply
Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 35,699+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Ruby on Rails tutorials, guides, and screencasts for web developers learning Ruby, Rails, Javascript, Turbolinks, Stimulus.js, Vue.js, and more. Icons by Icons8

    © 2020 GoRails, LLC. All rights reserved.