Rails and CKEditor

Has anyone used CKEditor successfully with Rails? Specifically the
file/image upload?

I have the ckeditor working rather well but this aspect. I have the
upload tab on the popup and it allows the user to browse their computer
for an image and then click “Send to Server”

This is where it breaks. I get a routing error “No route matches
“/uploader/upload.php”” which actually makes sense b/c I can’t find that
directory and/or file within the ckeditor files.

Do I need to download these separately?
or
Do I need to create this upload functionality myself?

Either way is fine by me but I just don’t want to spend time working on
one solution if there is an easier or already ‘in-place’ solution that
I’m missing.

Any help would be appreciated.

On Tue, Sep 20, 2011 at 4:14 PM, Keith R. [email protected]
wrote:

Do I need to download these separately?
or
Do I need to create this upload functionality myself?
Hi Keith,
You have to create the upload functionality yourself and then specify
the upload URL in the CKEditor configuration, like this:
filebrowserUploadUrl: “/gallery/upload”

Also you’ll need to create the file browser yourself, and specify it
with the next configuration option:
filebrowserImageBrowseUrl: “/gallery”

Note that the “gallery” and “/gallery/upload” route names are the ones
I’ve chosen for my app, you can choose whatever you want as long as
they are valid routes for your app.

Hope it helps.

Cheers!


Leonardo M…
There’s no place like ~

Has anyone used CKEditor successfully with Rails? Specifically the
file/image upload?

I use elfinder (version 1) with CKEditor and it works great. Follow the
instructions on the elfinder site to integrate the front end and use the
el_finder gem on the backend…

-philip

Thanks for the replies!

I looked into the el_finder, but this is using jQuery and I’m building
this out in prototype. If I use that gem would that add any real bloat
to my application? I have always been weary of having too many calls to
javascript files and having two libraries loading seems wrongish…

I tried creating a route for uploading. I simply created a ‘match
“/upload” => controller#action, :via => :post’ But this is causing all
kinds of issues with Devise gem that is handling my login/out. Every
time I click ‘send to server’ it logs me out of my application and
doesn’t even hit my :action that it is supposed to be getting to.

Any thoughts? Again thank you both for helping me thus far.

On Tue, Sep 20, 2011 at 7:37 PM, Philip H. [email protected]
wrote:

Has anyone used CKEditor successfully with Rails? Specifically the
file/image upload?

I use elfinder (version 1) with CKEditor and it works great. Follow the
instructions on the elfinder site to integrate the front end and use the el_finder
gem on the backend…

GitHub - phallstrom/el_finder: Ruby gem to provide server side connector to elFinder (open-source file manager for web)

Nice!
I didn’t know this. Looks good.


Leonardo M…
There’s no place like ~

Leonardo,

That’s exactly what it is. Thanks!

I commented out the before_filter that handles devises authentication
and the app was able to find the route as it should.

I read this somewhere too, I believe with authlogic or maybe it was
devise. Any ideas on a work around? I’m concerned about allowing this
action go without user authentication for security reasons…

Thanks again

On Wed, Sep 21, 2011 at 10:23 AM, Keith R. [email protected]
wrote:

Thanks for the replies!

I looked into the el_finder, but this is using jQuery and I’m building
this out in prototype. If I use that gem would that add any real bloat
to my application? I have always been weary of having too many calls to
javascript files and having two libraries loading seems wrongish…
I don’t think you would add any bloat, since you can use non-conflict
mode, but you will have to load both frameworks which is overkill and
kinda wrong.

I tried creating a route for uploading. I simply created a ‘match
“/upload” => controller#action, :via => :post’ But this is causing all
kinds of issues with Devise gem that is handling my login/out. Every
time I click ‘send to server’ it logs me out of my application and
doesn’t even hit my :action that it is supposed to be getting to.

Any thoughts? Again thank you both for helping me thus far.
This might be because of a before_filter that Devise must be adding to
require authentication.
I don’t use Devise, so I can’t tell for sure, it’s just a thought.

Hope it helps.


Leonardo M…
There’s no place like ~

Ok, I found this post:
ruby on rails - Devise being logged out on post to different route - Stack Overflow

and it showed me that the ‘protect_from_forgery’ method is the culprit
here and commenting it out makes this functionality work how it is
supposed to. Again it makes me nervous to leave this method out.

Does anyone know of a way to fix this or work around the
‘protect_from_forgery’ for just this :upload action?

I’m not really finding anything on fixing this issue via google

On Tue, Sep 27, 2011 at 10:21 AM, Keith R. [email protected]
wrote:

Leonardo,

That’s exactly what it is. Thanks!

I commented out the before_filter that handles devises authentication
and the app was able to find the route as it should.

I read this somewhere too, I believe with authlogic or maybe it was
devise. Any ideas on a work around? I’m concerned about allowing this
action go without user authentication for security reasons…

Hey, sorry for the late on this.
You should use a skip_before_filter, :only => :upload in your
controller.
Check guides.rubyonrails.com, if you’re in doubt with the syntax.

Hope it helps.

Cheers.

For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.


Leonardo M…
There’s no place like ~