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

Releases: chanzuckerberg/sorbet-rails

0.6.0

29 Feb 20:26
403c283
Compare
Choose a tag to compare

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); end

See: 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
end

See: https://github.com/chanzuckerberg/sorbet-rails#controllers

0.5.9.1

13 Dec 19:00
c2b2550
Compare
Choose a tag to compare

Hotfix to fix code generation for belongs_to association.

0.5.9

12 Dec 23:02
46df94a
Compare
Choose a tag to compare

Release 0.5.9

  • Generate better sigs for belongs_to association 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

19 Oct 21:37
f014e70
Compare
Choose a tag to compare

Minor bug fix for belongs_to check

0.5.8

16 Oct 22:36
90fa0b8
Compare
Choose a tag to compare

Bug fixes:

  • Fix belongs_to to respect 2 settings, belongs_to_required_by_default and required. Thanks Corey Farewell @frewsxcv
  • Fix the signature of the setter for a has_many association to accept T::Enumerable
  • Fix the mailer rake task to generate correct signature for methods that use keyword arguments
  • Improve ShrinePlugin

0.5.7

08 Oct 18:55
006ce0a
Compare
Choose a tag to compare
  • Add pluck_to_tstruct as a replacement for pluck
  • Remove block parameter from querying methods like select. Thanks to Riley Klinger (@riley-klingler)
  • Add a warning about adding sorbet-rails to runtime environment. Thanks to Alex Ghiculescu @ghiculescu
  • Allow symbols to be assignable for string attributes. Thanks to Matthew Griisser @mgriisser
  • When using rails_rbi:models with 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

19 Sep 01:13
65ac98d
Compare
Choose a tag to compare
  • Relation#each now return an array, not void. Thanks Patrick Ellis @pje
  • Add a helpers method 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

15 Sep 05:16
67e4f0e
Compare
Choose a tag to compare
  • Fix enum generation doesn't work for subclass of a class with enum
  • Fix totally hide type_assert_impl from sorbet init)
  • Add IntegerString & BooleanString. They'll be useful for type-checking input params.

0.5.5

14 Sep 22:17
397d971
Compare
Choose a tag to compare

0.5.4

10 Sep 23:34
2e503a1
Compare
Choose a tag to compare
  • 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 & suffix on 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!