latest, rspec, Testing / 16.08.2019

In case you are having troubles to use the [ruby] expect_any_instance_of [/ruby] From Rspec, guess what, it is not only you, many of us have faced the same troubles before, you can see it here in the thread discussion https://github.com/rspec/rspec-mocks/issues/910 I really agree with this argument: The name of the method is...

generales / 23.06.2019

Ahora una triste historia para programadores/arquitectos de software: Erase una vez una clase llamada `God` la cual implementaba el método `create_planet` [ruby] Class God def self.create_planet Earth.new end end [/ruby] Cierto día fue invocada por primera vez [ruby] @earth = God.create_planet [/ruby] La instancia Earth(Tierra) era maravillosa y resplandeciente, llena...

activerecord, backend, Rails, Ruby / 11.05.2018

[ruby] your_model = User column_names = your_model.column_names - ['created_at', 'updated_at'] # we can ignore some unimportant fields backup_array = [] your_model.find_each(batch_size: 500) do |your_record| p_hash = {} column_names.each do |col_name| p_hash.merge!("#{col_name}" => your_record.send(col_name)) end backup_array << p_hash end [/ruby] This will create an array of...