# sorbet_erb

> Extracts Ruby code from ERB files so you can run Sorbet over them

Source: https://talira.ai/catalog/sorbet-erb-6v1r7dwc
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Command-line tool, Library
- Categories: [developer tools / type checking / templates](https://talira.ai/categories/developer-tools/type-checking/templates), [developer tools / type checking](https://talira.ai/categories/developer-tools/type-checking), [languages / ruby / rails](https://talira.ai/categories/languages/ruby/rails)
- Licence: MIT[^2][^3]
- Pricing: Free and open source[^2]
- Pricing notes: Free and open source (MIT).
- Free tier: yes[^2]
- Self-hostable: yes
- Creator: Franklin Hu

sorbet_erb is a small Ruby gem that parses a Rails app's ERB templates and writes the Ruby code inside them to plain Ruby files, wrapped in a class scoped to the app's `ApplicationController`, so that [Sorbet](https://talira.ai/catalog/sorbet-7qt3f670.md) can type-check what the views call. You run `bin/sorbet_erb ./app ./sorbet/erb`, keep the output directory out of git, and run Sorbet as usual; it assumes the app already uses Sorbet with [Tapioca](https://talira.ai/catalog/tapioca-mqtavm7c.md) for RBIs. Partials and Turbo Streams need strict locals, and an experimental `locals_sig` magic comment gives their locals Sorbet types. It is one developer's project (Franklin Hu), with nine releases since September 2024, the latest in July 2026.

## Links

- GitHub: https://github.com/franklinhu/sorbet_erb

## Problems it solves

- Sorbet doesn't check the Ruby inside our Rails ERB views, so typos in helper calls only fail at runtime
- type-check Rails view templates in CI along with the rest of our Sorbet-typed app
- give partial locals real types so a view gets a type error when a caller passes the wrong object
- catch a renamed model method that a view template still calls before it reaches production
- extract the Ruby code from ERB files into plain Ruby files that a static analyzer can read

## Features

- extracts Ruby from Rails ERB templates into Ruby files Sorbet can check
- generated code is scoped to the app's ApplicationController
- locals_sig magic comment gives partial locals Sorbet signatures (experimental)
- skips partials without strict locals unless skip_missing_locals is set
- YAML configuration with extra_includes for modules Tapioca doesn't cover
- nominal ViewComponent support

## Limitations

- Works only with Rails applications: generated code is scoped to a Rails ApplicationController[^1]
- Partials and Turbo Streams without strict locals are skipped unless skip_missing_locals is set[^1]
- No real type checking of ViewComponent instance variables: ViewComponents are only nominally supported[^1]

## Capabilities

- Has a command line tool: plan not known
- Has official SDKs: plan not known

## Trust

Overall: 0.28 out of 1.
Signals: backing 0.20, extensibility 0.20.

- created by Franklin Hu

Warnings:

- GitHub activity not fetched yet

## Related

- Works with [Sorbet](https://talira.ai/catalog/sorbet-7qt3f670.md)
- Works with [Tapioca](https://talira.ai/catalog/tapioca-mqtavm7c.md)
- Works with [Ruby on Rails](https://talira.ai/catalog/ruby-on-rails-xkdcpj5k.md)

## Alternatives

- [Sorbet for Rails](https://talira.ai/catalog/sorbet-for-rails-gqfgx58c.md): A Sorbet build for Rails apps that type-checks specs, factories, and ERB views
- [sorbet_view](https://talira.ai/catalog/sorbet-view-9t5njasp.md): Extracts Ruby code from view templates (ERB, etc.) for Sorbet type-checking, with LSP support

## Sources

[^1]: https://github.com/franklinhu/sorbet_erb (checked 20 Nov 2026)
[^2]: https://github.com/franklinhu/sorbet_erb/blob/main/LICENSE (checked 20 Nov 2026)
[^3]: https://rubygems.org/gems/sorbet_erb (checked 20 Nov 2026)
