Activity
Thanks for this lesson, it's very helpful.
One small tip in case anybody else runs into an error about UnknownAttributeError
when using this approach for accepts_nested_attributes
on an association that uses has_one
instead of has_many
. In the has_one
setup, the parameters hash does not need the "id" used in the fields_for()
call. If you include it then you get the UnknownAttributeError
because of the id. This is nothing to do with turbo and can be reproduced in the rails console.
So, if using has_many, then include the "id"s in the fields_for.
If using has_one, do not!
There's a bug in ActiveStorage. Wrap your call in url_for() to work around it.
# BUG: Uses http://example.com/... when rendering via a model broadcast
# See https://github.com/rails/rails/issues/41795
url_for(obj.avatar.variant(resize: "#{size}x#{size}!"))
Hey Chris, thanks for the video! I'm just wondering about the design decision to have a stream subscription for each individual comment for the broadcast removal vs broadcasting to the "container" comments stream along with the id of the comment to remove.
Is there a reason for doing it this way? Wondering if this would scale to a page with 1000 comments for example. Would that require 1001 websocket connections?
Nice overview of the techniques. Thanks!