Modularizing Rails Apps with Cells
Upcoming SlideShare
Loading in...5
×
 

Modularizing Rails Apps with Cells

on

  • 4,256 views

How to use the Gem Cells

How to use the Gem Cells

Statistics

Views

Total Views
4,256
Slideshare-icon Views on SlideShare
3,054
Embed Views
1,202

Actions

Likes
1
Downloads
8
Comments
0

5 Embeds 1,202

http://www.flaviamissi.com.br 744
http://blog.giran.com.br 454
url_unknown 2
http://twitter.com 1
http://us-w1.rockmelt.com 1

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Modularizing Rails Apps with Cells Modularizing Rails Apps with Cells Presentation Transcript

    • 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
                • show.html.erb
            • post/
                • index.html.erb
            • abstract_post_cell.rb
            • post_cell.rb
      Inheritance
    • Some interesting links
      • http://cells.rubyforge.org/examples.html
      • http://nicksda.apotomo.de/2010/12/pragmatic-rails-thoughts-on-views-inheritance-view-inheritance-and-rails-304/
      • https://github.com/apotonick/cells