Hobo / hobo

The web app builder for Rails (moved from tablatom/hobo)
http://hobocentral.net
103 stars 39 forks source link

Fix for hobo issue #193 (https://github.com/Hobo/hobo/issues/193) #194

Closed egomolka closed 6 years ago

egomolka commented 7 years ago

hot-input throws "no route" exception when relative_url_root is used

Background/steps to recreate I am integrating a Hobo app with other applications, and need to run it from a non-root directory. I therefore made changes to config.ru, and the environment files (development.rb and production.rb).

config.ru now looks like:

require ::File.expand_path('../config/environment', FILE) map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do run Rails.application end

Environment files that need the relative url root (development.rb/production.rb/test.rb) now have one more line, in order to provide the correct routes for menu links:

routes.default_url_options= {:script_name => Rails.application.config.relative_url_root}

Now I can start the application:

env RAILS_RELATIVE_URL_ROOT=/url_test jruby -S rails server

I create a new employee. The new employee dryml page has a hot-input tag. When the triggering selection is made, hot-input doesn't work. The log contains the message:

ActionController::RoutingError (No route matches "/url_test/employees/new"): app/controllers/employees_controller.rb:33:in `new'

All other features seem to work. The employee can still be created if the hot-input failure doesn't affect a required field.

This fix modifies the logic that creates the page_path variable, which previously assigned the request.fullpath to the page_path. It now assigns the fullpath minus the "script_name". The script_name contains the offset from the root directory.