Skip to content
This repository was archived by the owner on Jul 5, 2023. It is now read-only.

Releases: chanzuckerberg/sorbet-rails

0.5.3

30 Aug 20:10

Choose a tag to compare

  • Introduce SorbetRails.configure to enable provided gem plugins
  • Add simple plugins for PgSearch & FriendlyId gems

Checkout the documentation for more info

Thanks @connorshea for the contributions!

0.5.2

21 Aug 19:46
132ec91

Choose a tag to compare

  • Make rails model's relation classes usable at run time
    • Model::ActiveRecord_Relation
    • Model::ActiveRecord_AssociationsRelation
    • Model::ActiveRecord_Association_CollectionProxy
  • Fix generation logic for chaining relations on CollectionProxy
  • URL helpers now available on ActionView::Helpers. Thanks @connorshea

Please rerun rake rails_rbi:all to regenerate all rbi files.

0.5.1

17 Aug 02:22
e5a3935

Choose a tag to compare

  • Fix rails_rbi:helpers when there are no helpers defined.
  • Add a plugin for Kaminari gem.
    Thanks @connorshea!

v0.5.0

11 Aug 17:28
6c600c0

Choose a tag to compare

  • Added a Model RBI plugin system. You can now define custom plugins that generate rbi for methods added by gems and your private modules.
  • Added rake tasks rails_rbi:helpers to generate RBI for helper methods and rails_rbi:all for running all generation tasks. Thanks Connor Shea (@connorshea).
  • Fixed the generation sig when an enum column is nilable. Thanks Rohan Varnma (@rnvarma)
  • Fixes to make sorbet-rails work with recent changes in Sorbet's generic system.

When you upgrade, please:

  1. Remove sorbet/rails-rbi/activerecord.rbi
  2. Regenerate rbi files rake rails_rbi:all
  3. Then regenerate hidden definitions srb rbi hidden-definitions

Special thanks to Aaron Christiansen (@AaronC81) for the Parlour rbi generation gem. It has made the recent changes much easier.

0.4.0

09 Jul 01:03
d559b0e

Choose a tag to compare

  • Fixes to make sorbet-rails to work with srb init and srb tc --lsp out of the box.
  • Various fixes to the bundled activerecord.rbi file to work with the new approach of bundling the file.
  • Load & generate RBI for models from Rails Engine (#76, thanks Pau Ramon Revilla @masylum)

Under the hood, sorbet-rails now copies the bundled activerecord.rbi file to the sorbet/rails-rbi/ folder instead of providing it in the gem's rbi/ folder. If after upgrade, sorbet complains about missing a sorbet-rails/rbi folder, please remove the cache folder ~/.cache/sorbet/gem-rbis/.

0.3.0

03 Jul 18:58
bf76cd1

Choose a tag to compare

  • Various fixes to the RBI generation code to work with Sorbet 0.4.4366 (#68)
  • Add support for Rails 4.2, 5.0, and 6.0.0.rc1 (#48, thanks @alexevanczuk; #53, #61)
  • Generate the unscoped method for each model (#57, thanks @gogiel)
  • Generate model-specific CollectionProxy and use it for associations (#30, thanks @halogenandtoast)
  • Generate column_name? method for all columns in a model (#45)
  • Generate enum_value! method for all enum values in a model (#70)
  • Fix bug with signatures that use blocks (#57, thanks @gogiel)
  • find_n now properly accepts a variable argument list (#63)

0.2.0

26 Jun 17:20
d43f947

Choose a tag to compare

  • Support Rails version 5.1.7 (#29)
  • Generate model methods in separate module, supporting generating overridden methods (#29)
  • Vendored RBI file now works automatically, without rbi_list or needing to run srb rbi (#26)
  • Improved type mapping from ActiveRecord <-> Sorbet/Ruby (#23, thanks @pje)
  • has_many associations now use ActiveRecord::Associations::CollectionProxy (#30, thanks @halogenandtoast)
  • Improved handling for abstract classes (#27, thanks @pje)

If you are upgrading from v0.1.3, you can remove @rbi_list from sorbet/config to make sorbet --lsp work.

Initial Release

20 Jun 02:29

Choose a tag to compare

This gem adds a few Rake tasks to generate Ruby Interface (RBI) files for dynamic methods generated by Rails. It also includes signatures for related Rails classes. The RBI files are added to a sorbet/rails-rbi/ folder.

ActiveRecord RBI

There is an ActiveRecord RBI file that we vendor with this gem. Run srb rbi sorbet-typed to include the provided RBI file in your sorbet/rbi_list.

Routes RBI

This Rake task generates an RBI file defining _path and _url methods for all named routes in routes.rb:

  $ rake rails_rbi:routes

Models RBI

This Rake task generates RBI files for all models in the Rails application (all descendants of ActiveRecord::Base):

  $ rake rails_rbi:models

You can also regenerate RBI files for specific models:

  $ rake rails_rbi:models[ModelName,AnotherOne,...]

The generation task currently creates the following signatures:

  • Column getters & setters
  • Associations getters & setters
  • Enum values, checkers & scopes
  • Named scopes
  • Model relation class