Modularizing Rails Apps with Cells

  • 3,780 views
Uploaded on

How to use the Gem Cells

How to use the Gem Cells

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
3,780
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
8
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 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 invoke erb create app/cells/tags/display.html.erb invoke rspec 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 < Cell :: Rails def display render end end Generated code
  • 7. What if I want to...
  • 8. Cache class TagsCell < Cell :: Rails cache :display , :expires_in => 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. <%= render_cell :tags , :display , :msg => &quot;Live long and prosper&quot; %> 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