ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Modularizing Rails Apps With Cells Flavia Missi @flaviamissi
Installation $  gem install cells Gemfile gem  'cells'
group  :test   do gem  " rspec-cells " end RSpec?
$  rails g cell tags display create   app/cells/tags_cell.rb invoke  erb create     app/cells/tags/display.html.erb invoke  rspec create     spec/cells/tags_cell_spec.rb $  rails g cell CellName actionName  Generator
Don't use erb? $  rails g cell Tags display  -e haml
class   TagsCell  <  Cell :: Rails def   display render end end Generated code
What if I want to...
Cache class   TagsCell  <  Cell :: Rails cache   :display ,   :expires_in   =>   10 .minutes ...
It looks like a controller... And it is! Works exactly like one ;)
Views Suports rendering other cells Works like Rails default views Are located in app/cells/your_cell_name/ folder
<%=  render_cell  :tags ,  :display ,  :msg  =>  &quot;Live long and prosper&quot;   %> Rendering Cells
What about the Models? Models are not part of a cell Cells are able to interact with a
model just like a controller does
Inheritance Cells inheritance Views inheritance
app cells abstract_post/ index.html.erb

More Related Content

Modularizing Rails Apps with Cells