问题
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:
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
来源:https://stackoverflow.com/questions/60073700/rails-using-puma-change-localhost3000-to-localhost3000-example