Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion rbi/annotations/railties.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,16 @@ class Rails::Application < ::Rails::Engine
end

class Rails::Engine < ::Rails::Railtie
sig { params(block: T.untyped).returns(ActionDispatch::Routing::RouteSet) }
sig { params(block: T.nilable(T.proc.bind(ActionDispatch::Routing::Mapper).void)).returns(ActionDispatch::Routing::RouteSet) }
Comment thread
vinistock marked this conversation as resolved.
def routes(&block); end

class << self
sig { returns(Pathname) }
def root; end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this defined? I can't see any Rails::Engine.root method.

@Morriar Morriar May 8, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@amomchilov amomchilov May 8, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like it's delegated https://github.com/rails/rails/blob/main/railties/lib/rails/engine.rb?#L436

That's Rails::Engine#root though, not the one I am asking about.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

method_missing 🤮

https://github.com/rails/rails/blob/747f85f200e7bb2c1a31b4e26e5a5655e2dc0cdc/railties/lib/rails/railtie.rb#L221-L229

Right, but also that means all class methods are delegated to instance methods, not just root.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I didn't get that far, root was the only sig I needed :D

end

sig { returns(Pathname) }
def root; end
end

class Rails::Railtie
Expand Down