Skip to content

Commit f082bcf

Browse files
rubysclaude
andcommitted
runtime(cruby): the overlay Request answers #host
There are two `ActionDispatch::Request` implementations — the shared transpilable one (`runtime/ruby/action_dispatch/request.rb`) and the CRuby overlay over the CGI env, which is the one `main.rb` actually requires. The shared one has always had `host`; the overlay built the same string INSIDE `base_url` and exposed nothing. That made `Rails.application.domain` — the framework default every `_url` helper grounds against, added in 7a09ba9 as `ActionController::Current.request.host` — raise NoMethodError on any app that does not define `domain` itself. campfire's message row links each message by `room_at_message_url`, so it was every message. `base_url` now composes from it rather than repeating the fetch, so the two cannot drift. Verified over the batch: cargo test (all green), compare ruby 7/7, smoke ruby 6/6, crystal 3/3 + rust 2/2 + spinel 1/1. The lobsters emit differs in exactly this one runtime file and nowhere else. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 872b754 commit f082bcf

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

runtime/spinel/scaffold/ruby_overlay/runtime/action_dispatch_request.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,19 @@ def original_url = "#{base_url}#{fullpath}"
6262
# (campfire stores it as the post-login return path).
6363
def url = original_url
6464

65+
# Host (with port when the client sent one), as Rails reports it.
66+
# The shared `ActionDispatch::Request` has always carried this; the
67+
# overlay twin did not, and `Rails.application.domain` — the
68+
# framework default every `_url` helper grounds against — reads it.
69+
# So an app with no `domain` of its own raised NoMethodError on its
70+
# first absolute URL: campfire's message row, which links each
71+
# message by `room_at_message_url`.
72+
def host
73+
@env["HTTP_HOST"] || @env["SERVER_NAME"] || "localhost"
74+
end
75+
6576
def base_url
6677
scheme = @env["HTTPS"] == "on" ? "https" : "http"
67-
host = @env["HTTP_HOST"] || @env["SERVER_NAME"] || "localhost"
6878
"#{scheme}://#{host}"
6979
end
7080

0 commit comments

Comments
 (0)