I am new to ruby on rails but I am not finding the meaning of this line of code. I saw in the documentation of rails that select will build an array of objects from the database for the scope, converting them into an array and iterating through them using Array#select. Anyway I can’t understand the result of this line of code and on what it consists.
model.legal_storages.select{|storage| storage.send(document_type)==true}.last
model.legal_storagesisn't already loaded I would go for a direct query instead.model.legal_storages.where(document_type => true).lastIfmodel.legal_storagesis loaded I would use the square bracket notation to make sure only attributes can be invoked.model.legal_storages.select{|storage| storage[document_type] }.last