2

I have developed a rails 5 application that works fine in http://localhost:3000/

Now, I need that this application starts in localhost:3000/example, and that links goes through this new host, (localhost:3000/example/users/new for example). I have got that assets and javascripts works fine in localhost:3000/example with:

config.root_path = '/example'

but links still redirects to the old one (for example, localhost:3000/users/new).

Anyone know how can I fix it? Thanks in advance

1 Answers1

2

wrap your entire routes configurations in a scope

#config/routes.rb

Rails.application.routes.draw do
   scope '/example' do
     #all the routes goes here
   end
end

you can change how assets delivery path with this

for more info : https://guides.rubyonrails.org/routing.html#controller-namespaces-and-routing

#config/application.rb

config.action_controller.asset_host = "example.com"
config.assets.prefix = '/example'

https://guides.rubyonrails.org/v3.0.3/configuring.html#configuring-action-controller

Nijeesh Joshy
  • 1,279
  • 9
  • 17