Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WYSIWYG image uploads in Rails App

Can anyone recommend a way of creating a view where users can upload images to my app through a WYSIWYG editor?

I've tried solving this using CK Editor and Paperclip but am having lots of trouble... Maybe I'm going about this the wrong way.

If someone's done this before I'd really like to know how! I don't have a editor or file storage mechanism preference so fire away...

like image 622
Ganesh Shankar Avatar asked Feb 17 '10 00:02

Ganesh Shankar


People also ask

Why can't I use WYSIWYG in rails?

The problem with using a WYSIWYG in Rails is tying it into the backend, especially with the image upload functionality. Because Rails handles image uploads differently to text, a separate flow is required. We currently use ckeditor (although Redactor is preferred)↴ CKEditor has been around since 2003, originally named FCKEditor:

What is the best WYSIWYG for image upload in rails?

These are quite common → TinyMCE, Redactor and CKEditor are the most popular. The problem with using a WYSIWYG in Rails is tying it into the backend, especially with the image upload functionality. Because Rails handles image uploads differently to text, a separate flow is required. We currently use ckeditor (although Redactor is preferred)↴

Can my users upload images to my rails app?

And there you have it. I hope this is helpful, in showing how to add a feature in your Rails app, so your users can upload images.

How do you handle image uploads in rails Orm?

The gem’s authors have also added several hooks into the Rails ORM system (ActiveRecord / Mongoid etc) which allows it to handle uploads: This gives the gem direct connectivity to the backend, allowing us to hook into the likes of Paperclip etc, for image uploads.


2 Answers

This is all dependent on the WYSIWYG's file upload API. From there, just build an ImagesController to handle requests from that API, use whatever system (Paperclip is good) to handle those files internally, and you should be good to go. You won't find a plug-and-play solution; you'll have to hand-roll it.

Turns out that, with more targeted Google searching, you can find a preexisting solution. Here's one for TinyMCE and Rails. You may, however, end up finding that it doesn't meet your needs, in which case I would not be surprised to find that creating your own solution would be simpler than you expect :)

like image 135
Matchu Avatar answered Sep 18 '22 12:09

Matchu


You could try Bootsy. It's a WYSIWYG editor with image upload capability. Includes a (rather simple) image manager as well.

https://github.com/volmer/bootsy

like image 44
Andreas Baumgart Avatar answered Sep 18 '22 12:09

Andreas Baumgart