Avoiding ActiveRecord callbacks

Поделиться
HTML-код
  • Опубликовано: 28 авг 2024
  • my products:
    typefast.gumro...
    work with me:
    www.typefast.c...

Комментарии • 9

  • @felipehansen4932
    @felipehansen4932 14 дней назад +1

    Hey, liked your point of view, a question, what you think about using callbacks, but also using ActiveModel::Dirty methods, example: inside the callback function 'return unless self.api_key_changed? || self.username_changed?' or some related logic ?

  • @swswisssw
    @swswisssw 4 месяца назад +3

    make a video where you will do the all process of installation ruby and rails on a Mac OS from scratch.

    • @cocoarecords
      @cocoarecords 4 месяца назад

      For real man!!! No gd explanation out there

  • @codeline9387
    @codeline9387 5 месяцев назад +3

    Thus, the active recording pattern is broken, the model can still become fat, it is better to move such code into service objects

  • @jiachen1078
    @jiachen1078 5 месяцев назад +2

    Maybe we can try to use the intersect?(set)? e.g. `attributes.keys.to_set.intersect?([:user_name, :api_key, :jira_domain].to_set)`

    • @ledockol
      @ledockol 5 месяцев назад +1

      Looks a little complicated)

    • @ledockol
      @ledockol 5 месяцев назад

      (user.attributes.keys & ['extra', 'api_key', 'jira_domain']).any?

    • @ranjansharma9990
      @ranjansharma9990 Месяц назад

      [:username, :api_key, :jira_domain].any? { |attr| attributes.keys.include?(attr) }