View Components in Rails



                Harun Pathan
                @harunpathan
Component
render_component
render_component



     Deprecated
View Directory Structure
View Directory Structure
But what happens when you have
unrelated sections on your main
              view




                                  5
7
What if
CMS is
used?




          10
What if
CMS is
used?

          How do
          we Mash
            Up?

                    10
How do we handle this?
How do we handle this?



Consider only one page with one
       unrelated section
How do we handle this?
How do we handle this?
How do we handle this?
How do we handle this?

What if some unrelated sections
  are used on all the pages?
How do we handle this?

What if some unrelated sections
  are used on all the pages?



What if there are many unrelated
            sections?
What happens to Views?
What happens to Views?

 Partials
What happens to Views?

 Partials
What happens to Views?

 Partials

 Some more partials
What happens to Views?

 Partials

 Some more partials
What happens to Views?

 Partials

 Some more partials

 And some more partials and so on…
Options
Merb Parts

   Rails Parts


Cells and Apotomo
Cells
Cells
Cells
Cells
Cells
Generators
Cells
Generators
Cells
Generators
Caching
Caching
Caching




Expiration in Sweepers
Cells

 Nested Cells
Cells

 Nested Cells
Cells

 Nested Cells

 View inheritance
Cells

 Nested Cells

 View inheritance
Cells

 Nested Cells

 View inheritance

 No doubleRenderError
Cells

 Nested Cells

 View inheritance

 No doubleRenderError
Hold on… there is more
Hold on… there is more


      APOTOMO
Reusable
Persistent


              APOTOMO

                            Events
Independent



                                     29
 Dashboards

 Image galleries

 Auto-Completion boxes

 AddressBooks

 TabPanels

 Social Components like Ratings/Comments
Apotomo
Apotomo
Apotomo
Apotomo
Apotomo
Apotomo
Apotomo




git://github.com/hpathan/apotomo-examples.git
Apotomo




git://github.com/hpathan/apotomo-examples.git
Apotomo




git://github.com/hpathan/apotomo-examples.git
Apotomo




git://github.com/hpathan/apotomo-examples.git
Apotomo




git://github.com/hpathan/apotomo-examples.git
Apotomo
    Index.html.erb




git://github.com/hpathan/apotomo-examples.git
Apotomo - Events
Example

    => Create a new note and Update
    listing and counter

    => Filter notes on typing


git://github.com/hpathan/apotomo-examples.git
Apotomo - Events




git://github.com/hpathan/apotomo-examples.git
Apotomo - Events




git://github.com/hpathan/apotomo-examples.git
Apotomo - Events




git://github.com/hpathan/apotomo-examples.git
Apotomo - Events




git://github.com/hpathan/apotomo-examples.git
Apotomo – Events




git://github.com/hpathan/apotomo-examples.git
Apotomo – Events




git://github.com/hpathan/apotomo-examples.git
Apotomo – Events




git://github.com/hpathan/apotomo-examples.git
Apotomo – Events




git://github.com/hpathan/apotomo-examples.git
Apotomo – Events




git://github.com/hpathan/apotomo-examples.git
Apotomo – Events




git://github.com/hpathan/apotomo-examples.git
Apotomo – Events




git://github.com/hpathan/apotomo-examples.git
Apotomo – Events




git://github.com/hpathan/apotomo-examples.git
Apotomo – Events




git://github.com/hpathan/apotomo-examples.git
Apotomo – Events & Widget
Apotomo – Events & Widget
                           Root




            Widget1               Widget2




Widget1.1             Widget1.2   Widget2.1
Apotomo – Events & Widget
                           Root




            Widget1               Widget2




Widget1.1             Widget1.2   Widget2.1
Apotomo – Events & Widget
                           Root




            Widget1               Widget2




Widget1.1             Widget1.2   Widget2.1
Apotomo – Events & Widget
                           Root




            Widget1               Widget2




Widget1.1             Widget1.2   Widget2.1
Thank You

Reusable View Components in Rails

Editor's Notes

  • #2 \n
  • #3 For more details C2.com on component based development\n
  • #4 Talk about MVC after talking about render_component\n
  • #5 We all like views, we should take good care of them\n
  • #6 \n
  • #7 We all like views, we should take good care of them\n
  • #8 \n
  • #9 \n
  • #10 \n
  • #11 \n
  • #12 \n
  • #13 \n
  • #14 \n
  • #15 \n
  • #16 \n
  • #17 \n
  • #18 \n
  • #19 \n
  • #20 \n
  • #21 \n
  • #22 \n
  • #23 \n
  • #24 \n
  • #25 \n
  • #26 \n
  • #27 \n
  • #28 \n
  • #29 \n
  • #30 \n
  • #31 \n
  • #32 \n
  • #33 \n
  • #34 - Cells can be nested\n Cells can have as many render as possible there would be no double render_error\n
  • #35 Caching: No fragment cache, strictly view caching\n\nTest:UNIT\n\nTwo types of testing …. Unit testing both ways Cells:TestCase Or ActionControler::TestCase\n\nTest your cells in isolation\n
  • #36 Caching: No fragment cache, strictly view caching\n\nTest:UNIT\n\nTwo types of testing …. Unit testing both ways Cells:TestCase Or ActionControler::TestCase\n\nTest your cells in isolation\n
  • #37 Caching: No fragment cache, strictly view caching\n\nTest:UNIT\n\nTwo types of testing …. Unit testing both ways Cells:TestCase Or ActionControler::TestCase\n\nTest your cells in isolation\n
  • #38 Caching: No fragment cache, strictly view caching\n\nTest:UNIT\n\nTwo types of testing …. Unit testing both ways Cells:TestCase Or ActionControler::TestCase\n\nTest your cells in isolation\n
  • #39 Caching: No fragment cache, strictly view caching\n\nTest:UNIT\n\nTwo types of testing …. Unit testing both ways Cells:TestCase Or ActionControler::TestCase\n\nTest your cells in isolation\n
  • #40 Caching: No fragment cache, strictly view caching\n\nTest:UNIT\n\nTwo types of testing …. Unit testing both ways Cells:TestCase Or ActionControler::TestCase\n\nTest your cells in isolation\n
  • #41 Caching: No fragment cache, strictly view caching\n\nTest:UNIT\n\nTwo types of testing …. Unit testing both ways Cells:TestCase Or ActionControler::TestCase\n\nTest your cells in isolation\n
  • #42 Caching: No fragment cache, strictly view caching\n\nTest:UNIT\n\nTwo types of testing …. Unit testing both ways Cells:TestCase Or ActionControler::TestCase\n\nTest your cells in isolation\n
  • #43 Apotomo is based on cells\n
  • #44 \n
  • #45 Apotomo is based on cells\n
  • #46 Apotomo is based on cells\n
  • #47 Apotomo is based on cells\n
  • #48 Apotomo is based on cells\n
  • #49 Apotomo is based on cells\n
  • #50 Apotomo is based on cells\n
  • #51 Apotomo is based on cells\n
  • #52 Apotomo is based on cells\n
  • #53 Apotomo is based on cells\n
  • #54 Apotomo is based on cells\n
  • #55 Apotomo is based on cells\n
  • #56 Apotomo is based on cells\n
  • #57 Apotomo is based on cells\n
  • #58 Apotomo is based on cells\n
  • #59 Apotomo is based on cells\n
  • #60 Apotomo is based on cells\n
  • #61 Apotomo is based on cells\n
  • #62 Apotomo is based on cells\n
  • #63 Apotomo is based on cells\n
  • #64 Apotomo is based on cells\n
  • #65 Apotomo is based on cells\n
  • #66 Apotomo is based on cells\n
  • #67 Apotomo is based on cells\n
  • #68 Apotomo is based on cells\n
  • #69 Apotomo is based on cells\n
  • #70 Apotomo is based on cells\n
  • #71 Apotomo is based on cells\n
  • #72 Apotomo is based on cells\n
  • #73 Apotomo is based on cells\n