how do i send pictures in channels?

24 views
Skip to first unread message

fugee ohu

unread,
Jan 19, 2020, 4:10:02 PM1/19/20
to Ruby on Rails: Talk
Got my chat app working in rails 6 with channels but now how do I let users send  pictures in channels? I've seen chat apps where after you upload the picture it displays with a circled button that says send and you can also delete it instead How do I do that?

Walter Lee Davis

unread,
Jan 19, 2020, 4:56:19 PM1/19/20
to rubyonra...@googlegroups.com


> On Jan 19, 2020, at 4:10 PM, fugee ohu <fuge...@gmail.com> wrote:
>
> Got my chat app working in rails 6 with channels but now how do I let users send pictures in channels? I've seen chat apps where after you upload the picture it displays with a circled button that says send and you can also delete it instead How do I do that?
>

With JavaScript. One of the neatest implementations I've seen of this is in Trix (ActionText), which is open-source, so you could see how they do it there. Also GitLab has a nice one, and the source is available for that (unlike GitHub, who also have one). You're basically intercepting the drop and paste events, checking to see whether the payload was an image, and then doing some out-of-band trickery to make a file attachment using a separate model and controller. Trix uses the new ActiveStorage goodies for its implementation. Not sure what the others use.

Walter

Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

fugee ohu

unread,
Jan 21, 2020, 11:44:18 PM1/21/20
to Ruby on Rails: Talk
Yes thanks I went with trix on this The problem I'm having now is ActionCable.server.broadcast unexpectedly sends a truncated version of the value of the rich text field over to my channel Maybe something in ActionCable config?
Reply all
Reply to author
Forward
0 new messages