relative_url_root doesn't work correctly with Rails 5.1.4

268 views
Skip to first unread message

Takuya Kusumoto

unread,
Oct 24, 2017, 10:52:25 AM10/24/17
to Ruby on Rails: Talk
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"

2. Modified config.ru as follows.
map ActionController::Base.config.relative_url_root || "/" do
  run Rails.application
end

3. Then start rails server
rails server puma -d -b 0.0.0.0

4. See the application application page

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

Takuya Kusumoto

unread,
Oct 24, 2017, 11:01:43 AM10/24/17
to Ruby on Rails: Talk
I guess asset compile is failing with relative_url_root...
Any bugs reported?

Kusumoto


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

botp

unread,
Oct 24, 2017, 11:25:55 AM10/24/17
to rubyonra...@googlegroups.com
see config.assets.prefix

Takuya Kusumoto

unread,
Oct 24, 2017, 11:45:19 AM10/24/17
to Ruby on Rails: Talk
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:

Takuya Kusumoto

unread,
Oct 24, 2017, 12:08:19 PM10/24/17
to Ruby on Rails: Talk
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:
Reply all
Reply to author
Forward
0 new messages