New Ruby on Rails

How to add Basic HTTP Authentication to a Ruby on Rails application

There is a certain stage in your application development process, where you need to prevent visitors from accessing the staging or the beta version of the app. To prevent unwanted access, a very basic HTTP authentication system should be added. Such a thing in Rails is extremely easy to add. This post is focused on authenticating access to all application parts.

New Ruby

What is the difference between clone and dup in Ruby

When you want to protect objects from being changed inside the methods you send them, Ruby offers some methods to preserve that original objects will not get altered in method calls. These methods are: dup and clone which are very similar with two differences.

New Ruby

Avoid the use of unless conditional with an else clause in Ruby

In Ruby, there are three ways of negating conditions. The first one is the not keyword. The second one is with the negating ! (the bang operator of negation). The third and more natural sounding way of negating is the unless keyword. The keyword unless, express the exact same semantics as if not (expression) and if !(expression).