Modularizing Rails Apps with Cells

Embed Size (px)

DESCRIPTION

How to use the Gem Cells

Citation preview

  • 1. Modularizing Rails Apps With Cells Flavia Missi @flaviamissi

2. Installation $gem install cells Gemfile gem'cells' 3. group:test do gem" rspec-cells " end RSpec? 4. $rails g cell tags display create app/cells/tags_cell.rb invokeerb create app/cells/tags/display.html.erb invokerspec create spec/cells/tags_cell_spec.rb

  • $rails g cell CellName actionName

Generator 5. Don't use erb? $rails g cell Tags display-e haml 6. class TagsCell 10 .minutes ... 9. It looks like a controller... And it is! Works exactly like one ;) 10. Views

  • Suports rendering other cells
  • Works like Rails default views
  • Are located in app/cells/your_cell_name/ folder

11. "Live long and prosper" %> Rendering Cells 12. What about the Models?

  • Models are not part of a cell
  • Cells are able to interact with a

13. model just like a controller does 14. Inheritance

  • Cells inheritance
  • Views inheritance

15.

  • app
    • cells
        • abstract_post/
          • index.html.erb
        • 16. show.html.erb
  • post/
    • index.html.erb

abstract_post_cell.rb 17. post_cell.rb Inheritance 18. Some interesting links

  • http://cells.rubyforge.org/examples.html

19. http://nicksda.apotomo.de/2010/12/pragmatic-rails-thoughts-on-views-inheritance-view-inheritance-and-rails-304/ 20. https://github.com/apotonick/cells