An Argument for Using Cells, an Argument Against Using Cells in Rails

Written by on Apr 22 2016


Cells are great, but they’re like adding a safety railing to your Rails app. If you need the structure to be enforced, then use it. But if you already have the coding discipline then there are more drawbacks and don’t use them.

If you don’t know what “Cells” is, you can read about it here.

Arguments for Using Cells in Rails

Let me begin by saying I like Cells. Here are some good reasons to use them:

  • They help get your view logic out of your views.
  • They provide a structure for how to (and where to) encapsulate a fragment of your UI.
  • They encourage more partials.
  • They enforce coding discipline. Which is very good because you will learn this discipline via rote.

Arguments against Using Cells in Rails

  • It’s another framework for your team to learn.
  • Your web UI is not the only place your view logic is required.
  • Cells can replace a decorator gem like Draper.
  • A very common practice for Cells or Draper is to wrap object methods to pretty them up (like titleizing a title column).
  • You need this logic regardless of whether the title is rendered to a web page, an email, a csv file, put in your javascript, acted upon by a cron object, pulled via console for a one off report for your CFO, etc.
  • Cells tightly bind objects with partials. Which means you write a lot of code that’s meant for partials, as opposed to writing objects that represent data, that can be used in partials or other places.
  • If you already have the discipline and knowledge for keeping your logic out of your views and keeping your classes organized then Cells is just another layer of abstraction. If you don’t need to use it as a safety rail, then don’t.

One Last Point

I think many proponents of Cells will argue that it unclutters your decorator directory. I find this argument specious. Any logic you have in a decorator object is still needed. You’ve just moved it from somewhere in the decorator directory to somewhere in the cells directory.


Hi I'm Steven,

I wrote the article you're reading... I lead the developers, write music, used to race motorcycles, and help clients find the right features to build on their product.

Get Blog Updates