Staying D.R.Y With Before_Action

A popular mantra when learning Ruby is to be D.R.Y(Don’t Repeat Yourself), we do this in order to avoid looking like our friend Clint Eastwood up above. When building up a Rails application, you find yourself repeating code statements often; especially in your model controllers. Let’s take a look at a few CRUD actions in a controller for a post model within a blog application :