David Kimura PRO
Joined 7/18/2015
Drifting Ruby Owner
Ruby Rogues Panelist
David Kimura PRO said over 3 years ago on 10 Tips and Tricks :
Nice   ! That is definitely a more Convention over Configuration way to handle loading configs. Love it!

I think the episode example is useful for non-rails apps (ruby scripts or other frameworks), but I would definitely prefer config_for in Rails apps.

David Kimura PRO said over 3 years ago on SOLID - Liskov Substitution Principle :
 

Interface Segregation Principle - ISP
(source - https://www.honeybadger.io/blog/ruby-solid-design-principles/)

The interface segregation principle is applicable to static languages, and since Ruby is a dynamic language, there is no concept of interfaces. Interfaces define the abstraction rules between classes.

The Principle states,

Clients should not be forced to depend upon interfaces that they don't use. - Robert C. Martin

What this means is that it is better to have many interfaces than a generalized interface that any class can use. If we define a generalized interface, the class has to depend on a definition that it does not use.

Dependency Inversion Principle - DIP

I think that Thoughtbot has the best explanation for this. https://thoughtbot.com/blog/back-to-basics-solid#dependency-inversion-principle

The Dependency Inversion Principle has to do with high-level (think business logic) objects not depending on low-level (think database querying and IO) implementation details. This can be achieved with duck typing and the Dependency Inversion Principle. Often this pattern is used to achieve the Open/Closed Principle...

David Kimura PRO said over 3 years ago on Authentication from Scratch :
  you are essentially putting a pause on that thread so it is not ideal. However, I think that it must be weighed given the situation with potentially leaking exposing customer emails. This was more of an illustration of one of the things that a developer may not think of that a bad actor may.

I am not sure about Heroku default app servers. I typically would use the Procfile to specify booting up Puma, so that would probably be a non issue. Their documentation does have a recommendation for using Puma as well. https://devcenter.heroku.com/articles/ruby-default-web-server#production-web-server

David Kimura PRO said over 3 years ago on Authentication from Scratch :
The authenticate method is an alias for some meta programming that's going on in the module that is included by has_secure_password.

https://api.rubyonrails.org/classes/ActiveModel/SecurePassword/InstanceMethodsOnActivation.html

  define_method("authenticate_#{attribute}") do |unencrypted_password|
    attribute_digest = public_send("#{attribute}_digest")
    BCrypt::Password.new(attribute_digest).is_password?(unencrypted_password) && self
  end

  alias_method :authenticate, :authenticate_password if attribute == :password

So, it basically just calls BCrypt to check with the method is_password? if they are a match.

David Kimura PRO said over 3 years ago on Record Audio to Active Storage :
  Yes, and you would likely not use any of the Stimulus controller parts since the file is already generated. For audio files (and likewise with images), you should probably have some front end validation with the mime types that you would accept in a comma separated string. For example, in this case, you would accept MP3 (or similar).

<%= form.file_field :media, direct_upload: true, accept: 'audio/mpeg' %>