Jeffrey Soong
Joined 3/25/2020
Jeffrey Soong said about 4 years ago on Ruby Objects and Memoization :
can someone explain why do you need an instance method find to loop and find the record when the looping can be done in the class method? Wouldn't you be able to something like attached below?

class << self
 def find(id)
   return unless id
   new(USERS.find { |user| user[:id] == id })
 end
end

Jeffrey Soong said about 4 years ago on State Machines with AASM :
This is such a cool concept and aasm has so many stars on github, but I can't really imagine how this can be used a practical Rails setting. It feels like something the ActiveRecord callbacks or validations can achieve. Ultimately it seems to be providing some form of lifecycle hook?

Jeffrey Soong said about 4 years ago on API Structure and Error Handling :
Really awesome way to refactor the json_render. I've always felt something can be done there, but I could never quite place my finger on it. The consistency part really resonates, and for error responses, I return @resource.errors.full_messages so that I get an array of strings in human readable sentence.

Jeffrey Soong said about 4 years ago on ActiveRecord Callbacks :
is there any benefit to writing the generate_token with begin/end over something like that?

def generate_token
   while self.class.exists?(token: token)
     self.token = SecureRandom.hex(8)
   end
end

Jeffrey Soong said about 4 years ago on MultiTenant Payment Processing :
Ooh yes! This would be a fantastic episode! I think one of the things worth discussing is also how would you store the client's API keys and such (for their payment gateway provider). Different layer of security etc.