Rails relative_url does not configure links

After unsuccessful attempts using Passenger (see my other question), I managed to run the rails through a reverse proxy server in a subfolder. I added the lines

config.relative_url_root = "/App" config.action_controller.relative_url_root = "/App" 

in my midst. Now I can access my rails project at www.mySite.com/App. The problem is that links / paths do not add the "/ App" prefix. Thus, the link to "users" looks like this: www.mySite.com/users instead of www.mySite.com/App/users . How can i change this?

At least according to http://edgeguides.rubyonrails.org/configuring.html#deploy-to-a-subdirectory-relative-url-root I did everything right.

+5
source share
3 answers

I worked by setting up my reverse proxy and configuring my rails as follows. This is my corresponding apache file:

 <VirtualHost *:80> DocumentRoot /path/to/App/public ProxyPass /App http://127.0.0.1:9292/App ProxyPassReverse /App http://127.0.0.1:9292/App </VirtualHost> 

My config.ru looks like this:

 require ::File.expand_path('../config/environment', __FILE__) map '/App' do run Rails.application end 

The specified environment variables are set in /config/environment.rb. I am not sure if they are still needed:

 config.relative_url_root = "/App" config.action_controller.relative_url_root = "/App" ENV['RAILS_RELATIVE_URL_ROOT'] = "/App" ENV['ROOT_URL'] = "/App" 
+3
source

I'm not quite sure if I understand what you are trying to do, but I think that what you are describing essentially means all your controllers running "/App" or something like that. This will be in your routes.rb :

 namespace "App" do # Put your resources here, as however you defined them before, eg: resources :users, :decks, :cards, :revs, :sessions end 
0
source

In Rails 4.2, I had the same need and decided to change some configuration files. Routes.rb:

 Rails.application.routes.draw do scope :mytm do .... end end 

This does not require any changes to the application.

In addition, you need to reconfigure the asset pipeline in /config/initializers/assets.rb:

  Rails.application.config.assets.prefix = "/app/asset" .... 
0
source

Source: https://habr.com/ru/post/1210335/


All Articles