Chris Valentine
Joined
Activity
Nice video. Will there be more on the other features you mentioned, such as recording, broadcasts, etc.?
renderer = ChatMessagesController.renderer.new(
http_host: ENV['RAILS_APPLICATION_URL'].presence || 'http://localhost:3000' ,
https: Rails.env.production?
)
ActionCable.server.broadcast "stream:#{chat_message.stream.id}", {
chat_message: renderer.render(chat_message)
}
Had to set the host and ssl to get it to work, the defaults are going back to example.com . SSL was important to set right without it it did not work.
i realize this was just a $.ajax() call so it was taken care of. Thanks.
In the tutorials here, I've seen an ActionCable broadcast be initiated by a chat message save. The broadcast is sent via a relay to a background job and then the chatmessages on the clients update when that broadcast job is run.
In my app, i have a host that runs a chatroom. I'd like the host to click a button and have that button run a javascript command to tell ActionCable to send the "disable-chat" command to the clients that are in the host's chat. I know how the clients receive that message thru ActionCable but how can the host send that request. There is no database save going on and no form to submit.
I imagine in javascript on the hosts page there is something like . chat_consumer.send('chatroom.disable'); or something like that, without doing a form that submits the requests. How do I go about this? Thx
I tried this but the request.base_url is reporting as Http://example.org at that point. Hmm
This is the applicationhelper that is called
def profile_picture_with_class user, css_class, shape, width = 100
if (shape == :square)
placeholder_pic = "blank_profile_square.jpg"
else
placeholder_pic = "blank_profile_round.png"
end
image_path = user.profile_image.present? ? user.profile_image : placeholder_pic
image_tag(image_path, width: width, class: css_class)
end
Okay I mostly have my version of this tutorial working. however, my chat message shows the users avatar next to it. When redis does the job and adds the message to the div it prepends http://example.org/ to the image along with some other weird stuff creating a broken link. If I refresh the page the image is displayed correctly as an active_storage file from my app using my app's URL. How do I get methods that are called by redis jobs to know what host to prepend to url's that it creates? thanks
tried to delete this extra comment but the 3 dot menu in the upper right is not working :(
Can you explain why I want actioncable running on the about page, the contact us page, or any page before there is even a user signed in? Seems a lot of unnecessary traffic processing when it will not be used. Say my site has 50 pages only 1 of which even uses actioncable. Thanks.
Thanks for the tutorial but I'm struggling with understanding some of the concepts. This tutorial (and everyone I can find online) seems to assume actioncable is to be loaded on every page on the site. Is there any direction on say you only want this stuff happening on the ChatPage. not the About US page or the Main page or before a user has signed in. I cannot find any guidance on turning this off/on only if you are on the correct page that will be using it. Thanks