Rails, tinymce-rails multiple images path breaking because of "../../../"

86 Views Asked by At

Hi everyone I am trying use tinymce-rails and and also have an upload form. This works really well since I can call the images anywhere. Just about everything is working great. The images upload, the tinymce styles stuff.

Now the weird thing is tinymce keeps adjusting the file paths to add "../../../" and this breaks the photos when editing the text. It would actually work fine if it would just go up one more "../" count on the edit page, the pathing does work on the show page.

enter image description here enter image description here enter image description here

Does anyone have any direction they can give me?

1

There are 1 best solutions below

1
Ruby Racer On BEST ANSWER

As I can't know the source of this, I can provide a workaround.

In your model, let's call it Post, you might need to replace stuff to the field containing the html, let's call it body:

before_save {
    body.gsub!(/(\.\.\/)+/,"..\/")
}