Releases: chanzuckerberg/sorbet-rails
0.5.3
- Introduce
SorbetRails.configureto 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
- 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
- Fix
rails_rbi:helperswhen there are no helpers defined. - Add a plugin for Kaminari gem.
Thanks @connorshea!
v0.5.0
- 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:helpersto generate RBI for helper methods andrails_rbi:allfor 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-railswork with recent changes in Sorbet's generic system.
When you upgrade, please:
- Remove
sorbet/rails-rbi/activerecord.rbi - Regenerate rbi files
rake rails_rbi:all - 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
- Fixes to make
sorbet-railsto work withsrb initandsrb tc --lspout of the box. - Various fixes to the bundled
activerecord.rbifile 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
- 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
unscopedmethod for each model (#57, thanks @gogiel) - Generate model-specific
CollectionProxyand 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_nnow properly accepts a variable argument list (#63)
0.2.0
- 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_listor needing to runsrb rbi(#26) - Improved type mapping from
ActiveRecord<-> Sorbet/Ruby (#23, thanks @pje) has_manyassociations now useActiveRecord::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
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:routesModels RBI
This Rake task generates RBI files for all models in the Rails application (all descendants of ActiveRecord::Base):
$ rake rails_rbi:modelsYou 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