Miniposts

40 miniposts
Ruby on Rails

How to permit all parameters in Rails controller strong parameters

Sometimes, you are looking to permit all the parameters of your Rails model in controller strong parameters. Instead of specifying them explicitly, one by one, you can permit all of the model attributes. However, this is not a good practice for a production application. As the comment of the rails controller scaffold states as a reminder to: Never trust parameters from the scary internet, only allow the whitelist through.

Ruby

How to update your rbenv version with git

This minipost will demonstrate how to update rbenv version when you have installed it through git to your system. To be more specific, we will update rbenv from version 1.1.0 to version 1.1.1 via git pull.

Ruby

How to update your rbenv ruby version

When you install rbenv with git to your machine, it does not update automatically all the new available ruby versions. Therefore, you need to update by git pulling the latest stable release. This minipost will demonstrate step-by-step how to configure your rbenv with the latest stable release of Ruby.

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.

Ruby on Rails

How to run multiple rails server instances on your local machine

Most of the times, you are developing more than one rails project at the same time and you want to avoid switching directories and start/stopping your development server. Running multiple rails server instances on your local machine is a daily essential. This minipost will demonstrate how to run multiple server instances using the -p option.

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.

Ruby

How to keep your irb session prompt and output shorter

While experimenting with code snippets on your irb (Interactive Ruby Interpreter) session, you might want to keep things clearer. This minipost demonstrates how to hide session returns and make irb prompt shorter allowing better focus on code execution.

Ruby

Different ways of printing in Ruby

There are three basic output methods in Ruby: print, puts and p. All these methods are used to output messages, results and valuable information during the execution of a Ruby program. However, there are some differences which are going to be demonstrated in this minipost.

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).

Ruby on Rails

Get rid of the gem documentation once & for all by specifying it on .gemrc

When installing a new gem using the gem install command, the documentation generation takes time and space on your development machine. This minipost, will demonstrate the common ways to avoid documentation installation when using gem install command. You could eliminate gem documentation, when you install new gems by adding flags to gem install command or add couple of settings to .gemrc file.