Release Zobi: a gem to keep Rails controllers DRY

Zobi is a gem that helps mix several functionalities in a Rails controller.

In many projects at af83, we use similar gems, mainly for back-office interfaces.

So, we decided to extract these common behaviors into a gem to ensure the following points:

  • keep controllers DRY;
  • don't waste time reinventing the wheel;
  • apply our best practices;
  • ensure uniformity between all af83's projects.

To achieve this, Zobi uses these popular Rails gems:


Add Zobi to your Gemfile and run bundle install:

gem 'zobi', '~> 4.0.0.rc2'

Next, include the Zobi module in your controller and set the modules you want to include :

extend Zobi
behaviors :inherited, :scoped, :included, :paginated, :controlled_access, :decorated

Full documentation is available on the github page.

Included behaviors

Let's explain the purpose of each of Zobi's behaviors.


Helps you create CRUD very easily using the power of inherited_resource gem.

It also provides a mechanism to extract Strong Parameters filtering logic in custom classes which makes testing more simple than testing the controller itself.


Out of the box filters for your controllers indexes. You only have to declare your filters using the has_scope declaration and your collection will be filtered automatically.


Automatic pagination for your collections using the kaminari gem.


By using draper decorators, you'll have 3 main advantages:

  • views don't handle complex logic;
  • decorators are simple to test;
  • decorators behaviors can be shared between several views.


This module only works with ActiveRecord because it uses the Eager Loading Associations of Active Record.

It lets you fetch object relations using as few queries as possible.


We decided to start the versioning at 4.0.0 to follow the Rails versions because of the many dependencies between Zobi and Rails.

If you want to test Zobi in a real Rails app, you can use the dummy app available here:

blog comments powered by Disqus