ruby on rails - Ajax call triggering base URL in Apache + Passenger integration mode -
i trying configure multiple rails apps through httpd configuration file. working fine ajax calls triggering wrong url, example if application configured http://localhost/helloapp/ , has ajax call "/say_hello" trying "localhost/say_hello" instead of "localhost/helloapp/say_hello". below httpd configuration file located @ '/etc/httpd/conf/httpd.conf '. using centos.
<virtualhost *:80> servername localhost <directory /var/www/html > allow options -multiviews # uncomment if you're on apache >= 2.4: #require granted </directory> alias /helloapp /var/www/html/hello_application/public <location /helloapp> passengerbaseuri /helloapp passengerapproot /var/www/html/hello_application </location> <directory /var/www/html/hello_application/public> # multiviews must turned off. allow options -multiviews </directory> </virtualhost>
any time make http request url beginning /
, example /say_hello
, implied sending request path specify root url. root url domain, in case http://localhost/
.
so no matter how configure apache server, when make request /say_hello
, browser direct http://localhost/say_hello
. if want make request http://localhost/helloapp/say_hello
, have tell ajax go /helloapp/say_hello
in website code.
if rails app named "helloapp", in 1 of ways described here access application name in rails code. once have store in instance variable, @app_name
, template or javascript (or wherever making ajax request from). think looking along these lines:
var url = "/<%= @app_name %>/say_hello"; // ajax request new url variable
Comments
Post a Comment