# Cells *View Components for Rails.* ## Overview Cells allow you to encapsulate parts of your page into a separate MVC component. They look and feel like controllers, can run arbitrary code in an action and render views. While they improve your overall software architecture by abstracting logic into an encapsulated OOP instance, cells also maximise reuseability within or across projects. Basically, cells can be rendered anywhere in your code. Most people use them in views to replace a helper/partial/filter mess, as a mailer renderer substitute or hook them to routes and completely bypass `ActionController`. ## View Models Since version 3.9 cells comes with two "dialects": You can still use a cell like a controller. However, the new [view model](https://github.com/apotonick/cells#view-models-explained) "dialect" allows you to treat a cell more object-oriented while providing an alternative approach to helpers. While the old dialect still works, we strongly recommend using a cell as a view model. ## Installation ```ruby gem 'cells' ``` ## File Layout Cells are placed in `app/cells`. ``` app ├── cells │ ├── comment_cell.rb │ ├── comment │ │ ├── show.haml │ │ ├── list.haml ``` ## Generate Creating a cell is nothing more than ```shell rails generate cell cart show -e haml ``` ``` create app/cells/ create app/cells/cart create app/cells/cart_cell.rb create app/cells/cart/show.html.haml create test/cells/cart_test.rb ``` That looks very familiar. ## Render the cell Now, render your cart. Why not put it in `layouts/application.html.erb` for now? ```erb