1. Ruby / Говнокод #18942

    −32

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    # We have strange bug: when company's fresher salary is updated, CompanyAnnouncement.track_update
      # method is called.
      # This method helps to see, was object changed or not.
      # This is workaround. We should get rid of this method in future.
    
      def self.object_changed?(obj)
        # Warning: We can't have "return true if obj.changed?" here, because sometimes changed? method
        # returns true when object was not really changed.
        return false if !obj.changed?
    
        obj.changes.each do |k, v|
          if v[0] != v[1] && k != 'updated_at'
            return true
          end
        end
        false
      end

    Открываю индусский проект, который надо спасать. app/controllers - 60 контроллеров, ок. User.rb - 650 строк кода, ок. А вот и самый сок!

    Запостил: deadleaves1985, 30 Октября 2015

    Комментарии (1) RSS

    Добавить комментарий