relative_url_root doesn't work correctly with Rails 5.1.4

Hello.

I faced 404 errors for asset pipeline URLs when I set config.relative_url_root with Rails 5.1.4/

What I did was as follows.

  1. Put the following lines in development.rb.

ENV[“RAILS_RELATIVE_URL_ROOT”] = “/subdir”

config.relative_url_root = “/subdir”

  1. Modified config.ru as follows.

map ActionController::Base.config.relative_url_root || “/” do

run Rails.application

end

  1. Then start rails server

rails server puma -d -b 0.0.0.0

  1. See the application application page

http://localhost:3000/subdir

Some of asset URLs get 404 error and not shown.

Of course, commenting #1 works well.

Could you please advice how to fix this?

Someone, please try to do above as it’s easy to setup…

Thanks,

Kusumoto

I guess asset compile is failing with relative_url_root…
Any bugs reported?

Kusumoto

2017年10月24日火曜日 23時52分25秒 UTC+9 Takuya Kusumoto:

see config.assets.prefix

Thanks. Already tried. But the option changes asset directory under public.
It made the situation worse… (all of assets becomes 404)

2017年10月25日水曜日 0時25分55秒 UTC+9 bot Peña:

Finally solved.
The root cause was config.assets.debug = true in development.rb.

When I commented it, it worked!

The conclusion is config.assets.debug has a bug with relative_url_root.

Thanks,

Kusumoto

2017年10月25日水曜日 0時45分19秒 UTC+9 Takuya Kusumoto: