This repository was archived by the owner on Jul 5, 2023. It is now read-only.
Releases: chanzuckerberg/sorbet-rails
Releases · chanzuckerberg/sorbet-rails
0.6.0
Release 0.6.0
- Use T.attached_class to reduce the amount of generated code. Thanks to Connor Shea @connorshea
- Add TypedParams to parse action controller params into basic type. Thanks to Donald Dong @donaldong
- Generate T::Enum version of rails enum. Thanks to Alex Ghiculescu @ghiculescu for writing the doc.
- Add sig for
find_or_initialize_by/create_by/create_by!. Thanks to Matthew Griisser @mgriisser - Add
ActiveRecord::Relation#find_each. Thanks to Alex Ghiculescu @ghiculescu - Add
ActiveRecord::Relation#empty?. Thanks to Mikkel Malmberg @mikker
And bug fixes/doc fixes from Todd Siegel @toddsiegel, Daniel Gilchrist @DanielGilchrist
Details:
With TypedEnum now you can have T::Enum version of Rails Enum
sig { returns(T.nilable(Wizard::House)) }
def typed_house; end
sig { params(value: T.nilable(Wizard::House)).void }
def typed_house=(value); endSee: https://github.com/chanzuckerberg/sorbet-rails#enums
TypedParams is a generalized version of fetch_typed & require_typed, that allows parsing nested params structure
class MyCoolController < ApplicationController
class MyActionParams < T::Struct
const :id, T.nilable(Integer)
const :show, T.nilable(T::Boolean)
const :wands, T::Array[Integer]
end
sig { void }
def my_action
typed_params = TypedParams[MyActionParams].new.extract!(params)
# T.reveal_type(typed_params) => MyActionParams
# T.reveal_type(typed_params.show) => T.nilable(T::Boolean)
end
endSee: https://github.com/chanzuckerberg/sorbet-rails#controllers
0.5.9.1
0.5.9
Release 0.5.9
- Generate better sigs for
belongs_toassociation enforced in the DB layer - Reduce the number of signatures generated using a bundled active_record_relation.rbi. Thanks to Connor Shea @connorshea
- Improve setter methods for Integer/Float. Thanks to Alex Ghiculescu @ghiculescu
- Include Routes helpers in Mailers. Thanks to Alex Ghiculescu @ghiculescu
- Add gem plugins: active_flag and Paperclip. Improve Kaminari plugin. Thanks to Alex Ghiculescu @ghiculescu
- Do not break when encountering NotImplemented Error. Thanks to Stephen Becker @sbeckeriv
0.5.8.1
0.5.8
Bug fixes:
- Fix
belongs_toto respect 2 settings,belongs_to_required_by_defaultandrequired. Thanks Corey Farewell @frewsxcv - Fix the signature of the setter for a
has_manyassociation to acceptT::Enumerable - Fix the mailer rake task to generate correct signature for methods that use keyword arguments
- Improve ShrinePlugin
0.5.7
- Add
pluck_to_tstructas a replacement forpluck - Remove block parameter from querying methods like
select. Thanks to Riley Klinger (@riley-klingler) - Add a warning about adding
sorbet-railsto runtime environment. Thanks to Alex Ghiculescu @ghiculescu - Allow symbols to be assignable for string attributes. Thanks to Matthew Griisser @mgriisser
- When using
rails_rbi:modelswith specific models, regenerate the subclass of the models (for STI). Thanks to Palash Agarwal @palasha - Add a gem plugin for elastic search and shrine
- Fix a bug when mailer generation logic doesn't handle params without name.
When you upgrade, please rerun rake rails_rbi:all to update all rbi files.
0.5.6
Relation#eachnow return an array, not void. Thanks Patrick Ellis @pje- Add a
helpersmethod that includes all helper modules to Rails controllers. Thanks Connor Shea @connorshea - Set correct types for time, date and datetime columns. Thanks Dave Clark @clarkdave
- Factory methods (
new,create,create!) now returns correct object type. Thanks Connor Shea - Final release to drop support for Rails 4.2. It has reached its end of life.
The 0.5.x series can still be used to add bug fixes for Rails 4.2
0.5.5.1
0.5.5
- Add
params.require_typedandparams.fetch_typedto type check controller actions. See documentation: https://github.com/chanzuckerberg/sorbet-rails#controllers - Replace
implementation.withoverride.to work with sorbet 0.4.4755 - Some other small fixes
0.5.4
- We now generate rbi for mailers, with
rake rails_rbi:mailers. See https://github.com/chanzuckerberg/sorbet-rails#mailers - Make belongs_to relation non-nilable by default on Rails 5.0+. Thanks to Will Pride @wpride
- Support enum
prefix&suffixon Rails 5.0+. Thanks to David Buchan-Swanson @deecewan - Support enum with non-integer value. Thanks to David Buchan-Swanson
- Check if enum method names are valid before adding. Thanks to Will Pride
- Add ActiveStorage attachment methods on Rails 6.0. Thanks to Connor Shea @connorshea
- Add configuration option for including extra helpers as part of helpers.rbi. Thanks to Alex Ghiculescu @ghiculescu
Thanks everyone for your wonderful contributions!