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...
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 <ul><li>Suports rendering other cells </li></ul><ul><li>Works like Rails default views </li></ul><ul><li>Are located...
<%=  render_cell  :tags ,  :display ,  :msg  =>  &quot;Live long and prosper&quot;   %> Rendering Cells
What about the Models? <ul><li>Models are not part of a cell </li></ul><ul><li>Cells are able to interact with a
model just like a controller does </li></ul>
Inheritance <ul><li>Cells inheritance </li></ul><ul><li>Views inheritance </li></ul>
<ul>app <ul>cells <ul><ul><li>abstract_post/ </li><ul><ul><li>index.html.erb
Upcoming SlideShare
Loading in …5
×

Modularizing Rails Apps with Cells

4,272 views
4,159 views

Published on

How to use the Gem Cells

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,272
On SlideShare
0
From Embeds
0
Number of Embeds
1,254
Actions
Shares
0
Downloads
9
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Modularizing Rails Apps with Cells

  1. 1. Modularizing Rails Apps With Cells Flavia Missi @flaviamissi
  2. 2. Installation $ gem install cells Gemfile gem 'cells'
  3. 3. group :test do gem &quot; rspec-cells &quot; end RSpec?
  4. 4. $ 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 <ul>$ rails g cell CellName actionName </ul>Generator
  5. 5. Don't use erb? $ rails g cell Tags display -e haml
  6. 6. class TagsCell < Cell :: Rails def display render end end Generated code
  7. 7. What if I want to...
  8. 8. Cache class TagsCell < Cell :: Rails cache :display , :expires_in => 10 .minutes ...
  9. 9. It looks like a controller... And it is! Works exactly like one ;)
  10. 10. Views <ul><li>Suports rendering other cells </li></ul><ul><li>Works like Rails default views </li></ul><ul><li>Are located in app/cells/your_cell_name/ folder </li></ul>
  11. 11. <%= render_cell :tags , :display , :msg => &quot;Live long and prosper&quot; %> Rendering Cells
  12. 12. What about the Models? <ul><li>Models are not part of a cell </li></ul><ul><li>Cells are able to interact with a
  13. 13. model just like a controller does </li></ul>
  14. 14. Inheritance <ul><li>Cells inheritance </li></ul><ul><li>Views inheritance </li></ul>
  15. 15. <ul>app <ul>cells <ul><ul><li>abstract_post/ </li><ul><ul><li>index.html.erb
  16. 16. show.html.erb </li></ul></ul><li>post/ </li><ul><ul><li>index.html.erb </li></ul></ul><li>abstract_post_cell.rb
  17. 17. post_cell.rb </li></ul></ul></ul></ul>Inheritance
  18. 18. Some interesting links <ul><li>http://cells.rubyforge.org/examples.html
  19. 19. http://nicksda.apotomo.de/2010/12/pragmatic-rails-thoughts-on-views-inheritance-view-inheritance-and-rails-304/
  20. 20. https://github.com/apotonick/cells </li></ul>

×