refinerycms icon indicating copy to clipboard operation
refinerycms copied to clipboard

wymeditor not working when using a sub uri

Open mvdamme opened this issue 16 years ago • 6 comments

I'm trying to run a refinerycms site under a sub uri (i.e. the site resides under www.domain.com/myapp/ instead of under www.domain.com/myapp/) with Passenger. I have set "RailsBaseURI /myapp" and "config.action_controller.relative_url_root = '/myapp'", and both the site and the admin-environment are working.

When I try to edit a page however, the wymeditor doesn't appear, and I can't edit the page. This doesn't happen if I don't run the site under a sub uri.

The problem seems to be related to jQuery, since the google chrome developer-tools console lists the following error when running under a sub uri: "Uncaught TypeError: Cannot read property 'length' of undefined" jquery.js:552

If I don't run the site under a sub uri, there is no error on the console and everything is working.

I'm using jQuery 1.4.2 (it came with refinerycms), which is the most recent version according to the jQuery site.

mvdamme avatar Apr 06 '10 02:04 mvdamme

Has anyone else had any success running with a sub uri?

parndt avatar Apr 13 '10 01:04 parndt

I've also tried the latest nightly build of jquery (the one of today, 4/13/2010), but the problem remains...

mvdamme avatar Apr 13 '10 14:04 mvdamme

Likely it isn't jquery's fault.. It'd be useful to see the stacktrace of what goes on before that line in jquery.js .. Probably something we are doing that relies on a URL like /javascripts/something - or does sub uri somehow handle those?

parndt avatar Apr 16 '10 12:04 parndt

Is this problem still present? I'll close this but please reopen it if you're still seeing problems.

parndt avatar May 21 '10 05:05 parndt

Hi all, this has not been fixed. I have traced the problem to the source: core/app/assets/javascripts/refinery/boot_wym.js.erb:161

Specifically the code here: dialogPath: "<%= Refinery::Core::Engine.routes.url_helpers.admin_dialogs_path %>/"

The problem is that the url_helpers are not respecting the sub_uri. We need to make sure that Refinery::Core::Engine.config.action_controller.relative_root_url is reporting the correct sub_uri.

I'll keep you all posted if I find anything.

hattwj avatar Aug 03 '13 05:08 hattwj

The whole reason this came up is because I am deployed in a sub uri and wanted a way to test before deploying. Here is my process and my fix:

This is what I did to fix it:

in ./config/environments/development.rb

config.action_controller.relative_url_root = "/#{ENV['RAILS_RELATIVE_URL_ROOT']}"

in my refinery initializer @ ./config/initializers/refinery/core.rb

Refinery::Core::Engine.config.action_controller.relative_root_url="/#{ENV['RAILS_RELATIVE_URL_ROOT']}"
Refinery::Core::Engine.routes.default_url_options[:script_name]="/#{ENV['RAILS_RELATIVE_URL_ROOT']}"

optional You might also need to precompile assets. The refinery admin panel works fine without this, ~~but my other pages in refinery didn't get all of the javascript. This was the only bug I've had, and~~ I suspect its because of a silly hack I inserted while overriding refinery. The bug was my fault, and due do incorrect includes in my application.js file

RAILS_RELATIVE_URL_ROOT="/my_sub_uri" rake assets:precompile

Then startup development mode:

RAILS_RELATIVE_URL_ROOT=my_sub_uri thin start --prefix=/my_sub_uri -p 3010

Almost everything works. I think the only things that don't work are silly hacks that I made along the way to figuring this out.

hattwj avatar Aug 03 '13 21:08 hattwj