SlideShare a Scribd company logo
1 of 12
Download to read offline
Cells
Simon Courtois - @happynoff
Problématique
     Comment partager un widget entre les pages du site ?




github: apotonick/cells
Solution à l’ancienne
   # app/controllers/application_controller.rb
   class ApplicationController < ActionController::Base
     before_filter :set_shopping_cart

    private

     def set_shopping_cart
       @shopping_cart = ShoppingCart.for_user(current_user)
     end
   end



                   # app/views/layouts/application.html.erb
                   <%= render 'shared/shopping_cart', shopping_cart: @shopping_cart %>




                                    # app/views/shared/_shopping_cart.html.erb
                                    <% if @shopping_cart %>
                                      # shopping cart rendering
                                    <% end %>




github: apotonick/cells
Solution avec Cells

  # app/views/layouts/application.html.erb
  <%= render_cell :shopping_cart, :display, user: current_user %>




              # app/cells/shopping_cart_cell.rb
              class ShoppingCartCell < Cell::Rails
                def display(opts)
                  @shopping_cart = ShoppingCart.for_user(opts[:user])
                  render
                end
              end



                                 # app/cells/shopping_cart/display.html.erb
                                 <% if @shopping_cart %>
                                   # shopping cart rendering
                                 <% end %>




github: apotonick/cells
Avantages


              Séparation des responsabilités
              Meilleure organisation du code
                 app/
                   cells/
                      shopping_cart/
                        display.html.erb
                     shopping_cart.rb




github: apotonick/cells
Aller plus loin - actions
    # app/cells/shopping_cart_cell.rb
    class ShoppingCartCell < Cell::Rails
      def display(opts)
        @shopping_cart = ShoppingCart.for_user(opts[:user])
        render
      end

      def count(opts)
        shopping_cart = ShoppingCart.for_user(opts[:user])
        @items_count = shopping_cart.items_count
        render
      end
    end




                 # app/views/layouts/application.html.erb
                 <%= render_cell :shopping_cart, :display, user: current_user %>
                 <%= render_cell :shopping_cart, :count, user: current_user %>




github: apotonick/cells
Aller plus loin - cache


                 # app/cells/shopping_cart_cell.rb
                 class ShoppingCartCell < Cell::Rails
                   cache :display, expires_in: 10.minutes

                   def display(opts)
                     # ...
                   end
                 end




github: apotonick/cells
Aller plus loin - cache


                 # app/cells/shopping_cart_cell.rb
                 class ShoppingCartCell < Cell::Rails
                   cache :display do |cell, opts|
                     opts[:user]
                   end
                   def display(opts)
                     # ...
                   end
                 end




github: apotonick/cells
Aller plus loin - helpers

         # app/cells/shopping_cart_cell.rb
         class ShoppingCartCell < Cell::Rails
           helper MyAwesomeHelper

           def display(opts)
             @shopping_cart = ShoppingCart.for_user(opts[:user])
             render
           end
         end




                             # app/cells/shopping_cart/display.html.erb
                             <%= do_something_awesome %>




github: apotonick/cells
Installation



                            gem ‘cells’


            $ rails generate cell shopping_cart display




         http://github.com/apotonick/cells




github: apotonick/cells
Questions ?



github: apotonick/cells
Merci !
@happynoff

More Related Content

Viewers also liked

Multi tenancy with mvc3 and entity framework
Multi tenancy with mvc3 and entity frameworkMulti tenancy with mvc3 and entity framework
Multi tenancy with mvc3 and entity frameworkLasantha Bandara
 
Create a simple multitenant application with entity framework
Create a simple multitenant application with entity frameworkCreate a simple multitenant application with entity framework
Create a simple multitenant application with entity frameworkCharalampos Karypidis
 
Multi-tenancy in Private Clouds
Multi-tenancy in Private CloudsMulti-tenancy in Private Clouds
Multi-tenancy in Private CloudsPatrick Nicolas
 
Dependency sorting in Ruby with TSort
Dependency sorting in Ruby with TSortDependency sorting in Ruby with TSort
Dependency sorting in Ruby with TSortSimon Courtois
 
ConFoo 2015 - Supporting Multi-tenancy Applications with Java EE
ConFoo 2015 - Supporting Multi-tenancy Applications with Java EEConFoo 2015 - Supporting Multi-tenancy Applications with Java EE
ConFoo 2015 - Supporting Multi-tenancy Applications with Java EERodrigo Cândido da Silva
 
Monetizing Multi-Tenancy in SaaS by Sixteen Ventures. Presented at SaaS Unive...
Monetizing Multi-Tenancy in SaaS by Sixteen Ventures. Presented at SaaS Unive...Monetizing Multi-Tenancy in SaaS by Sixteen Ventures. Presented at SaaS Unive...
Monetizing Multi-Tenancy in SaaS by Sixteen Ventures. Presented at SaaS Unive...Lincoln Murphy
 
Suportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EESuportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EERodrigo Cândido da Silva
 
Replacing church slide share
Replacing church slide shareReplacing church slide share
Replacing church slide sharepresbytery
 
JavaOne LATAM 2015 - Batch Processing: Processamento em Lotes no Mundo Corpor...
JavaOne LATAM 2015 - Batch Processing: Processamento em Lotes no Mundo Corpor...JavaOne LATAM 2015 - Batch Processing: Processamento em Lotes no Mundo Corpor...
JavaOne LATAM 2015 - Batch Processing: Processamento em Lotes no Mundo Corpor...Rodrigo Cândido da Silva
 
Metering and Billing for Cloud Services
Metering and Billing for Cloud ServicesMetering and Billing for Cloud Services
Metering and Billing for Cloud ServicesRanjit Nayak
 
Webinar - Business Implications of SaaS Multi Tenancy
Webinar - Business Implications of SaaS Multi TenancyWebinar - Business Implications of SaaS Multi Tenancy
Webinar - Business Implications of SaaS Multi TenancyScioSales
 
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EEJavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EERodrigo Cândido da Silva
 
Open Architecture for Developing Multitenant Software-as-a-Service Applications
Open Architecture for Developing Multitenant Software-as-a-Service ApplicationsOpen Architecture for Developing Multitenant Software-as-a-Service Applications
Open Architecture for Developing Multitenant Software-as-a-Service ApplicationsJavier Mijail Espadas Pech
 
How to build customizable multitenant web applications - IPC11 Spring Edition
How to build customizable multitenant web applications - IPC11 Spring EditionHow to build customizable multitenant web applications - IPC11 Spring Edition
How to build customizable multitenant web applications - IPC11 Spring EditionStephan Hochdörfer
 
Multi Tenancy In The Cloud
Multi Tenancy In The CloudMulti Tenancy In The Cloud
Multi Tenancy In The Cloudrohit_ainapure
 
Saa s multitenant database architecture
Saa s multitenant database architectureSaa s multitenant database architecture
Saa s multitenant database architecturemmubashirkhan
 

Viewers also liked (20)

เกม Ox
เกม Oxเกม Ox
เกม Ox
 
022006 zaidi badi
022006   zaidi badi022006   zaidi badi
022006 zaidi badi
 
Multi tenancy with mvc3 and entity framework
Multi tenancy with mvc3 and entity frameworkMulti tenancy with mvc3 and entity framework
Multi tenancy with mvc3 and entity framework
 
Create a simple multitenant application with entity framework
Create a simple multitenant application with entity frameworkCreate a simple multitenant application with entity framework
Create a simple multitenant application with entity framework
 
Multi-Tenancy in the Cloud
Multi-Tenancy in the CloudMulti-Tenancy in the Cloud
Multi-Tenancy in the Cloud
 
Multi-tenancy in Private Clouds
Multi-tenancy in Private CloudsMulti-tenancy in Private Clouds
Multi-tenancy in Private Clouds
 
Dependency sorting in Ruby with TSort
Dependency sorting in Ruby with TSortDependency sorting in Ruby with TSort
Dependency sorting in Ruby with TSort
 
ConFoo 2015 - Supporting Multi-tenancy Applications with Java EE
ConFoo 2015 - Supporting Multi-tenancy Applications with Java EEConFoo 2015 - Supporting Multi-tenancy Applications with Java EE
ConFoo 2015 - Supporting Multi-tenancy Applications with Java EE
 
Monetizing Multi-Tenancy in SaaS by Sixteen Ventures. Presented at SaaS Unive...
Monetizing Multi-Tenancy in SaaS by Sixteen Ventures. Presented at SaaS Unive...Monetizing Multi-Tenancy in SaaS by Sixteen Ventures. Presented at SaaS Unive...
Monetizing Multi-Tenancy in SaaS by Sixteen Ventures. Presented at SaaS Unive...
 
Suportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EESuportando Aplicações Multi-tenancy com Java EE
Suportando Aplicações Multi-tenancy com Java EE
 
Replacing church slide share
Replacing church slide shareReplacing church slide share
Replacing church slide share
 
JavaOne LATAM 2015 - Batch Processing: Processamento em Lotes no Mundo Corpor...
JavaOne LATAM 2015 - Batch Processing: Processamento em Lotes no Mundo Corpor...JavaOne LATAM 2015 - Batch Processing: Processamento em Lotes no Mundo Corpor...
JavaOne LATAM 2015 - Batch Processing: Processamento em Lotes no Mundo Corpor...
 
Metering and Billing for Cloud Services
Metering and Billing for Cloud ServicesMetering and Billing for Cloud Services
Metering and Billing for Cloud Services
 
Webinar - Business Implications of SaaS Multi Tenancy
Webinar - Business Implications of SaaS Multi TenancyWebinar - Business Implications of SaaS Multi Tenancy
Webinar - Business Implications of SaaS Multi Tenancy
 
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EEJavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
JavaOne 2014 - Supporting Multi-tenancy Applications with Java EE
 
Open Architecture for Developing Multitenant Software-as-a-Service Applications
Open Architecture for Developing Multitenant Software-as-a-Service ApplicationsOpen Architecture for Developing Multitenant Software-as-a-Service Applications
Open Architecture for Developing Multitenant Software-as-a-Service Applications
 
Multi-Tenant Approach
Multi-Tenant ApproachMulti-Tenant Approach
Multi-Tenant Approach
 
How to build customizable multitenant web applications - IPC11 Spring Edition
How to build customizable multitenant web applications - IPC11 Spring EditionHow to build customizable multitenant web applications - IPC11 Spring Edition
How to build customizable multitenant web applications - IPC11 Spring Edition
 
Multi Tenancy In The Cloud
Multi Tenancy In The CloudMulti Tenancy In The Cloud
Multi Tenancy In The Cloud
 
Saa s multitenant database architecture
Saa s multitenant database architectureSaa s multitenant database architecture
Saa s multitenant database architecture
 

Similar to Cells

Rails antipattern-public
Rails antipattern-publicRails antipattern-public
Rails antipattern-publicChul Ju Hong
 
Rails antipatterns
Rails antipatternsRails antipatterns
Rails antipatternsChul Ju Hong
 
Resource and view
Resource and viewResource and view
Resource and viewPapp Laszlo
 
Introduction à Ruby
Introduction à RubyIntroduction à Ruby
Introduction à RubyMicrosoft
 
Intro to-rails-webperf
Intro to-rails-webperfIntro to-rails-webperf
Intro to-rails-webperfNew Relic
 
Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010Plataformatec
 
Templates, partials and layouts
Templates, partials and layoutsTemplates, partials and layouts
Templates, partials and layoutsKadiv Vech
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful RailsViget Labs
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful RailsBen Scofield
 
Modularizing Rails Apps with Cells
Modularizing Rails Apps with CellsModularizing Rails Apps with Cells
Modularizing Rails Apps with CellsFlavian Missi
 
Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...
Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...
Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...Coupa Software
 
How to disassemble one monster app into an ecosystem of 30
How to disassemble one monster app into an ecosystem of 30How to disassemble one monster app into an ecosystem of 30
How to disassemble one monster app into an ecosystem of 30fiyuer
 
Rails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiRails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiPivorak MeetUp
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialYi-Ting Cheng
 
What's new in Rails 4
What's new in Rails 4What's new in Rails 4
What's new in Rails 4Fabio Akita
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails DevsDiacode
 

Similar to Cells (20)

Rails antipattern-public
Rails antipattern-publicRails antipattern-public
Rails antipattern-public
 
Rails antipatterns
Rails antipatternsRails antipatterns
Rails antipatterns
 
Resource and view
Resource and viewResource and view
Resource and view
 
Dash of ajax
Dash of ajaxDash of ajax
Dash of ajax
 
Introduction à Ruby
Introduction à RubyIntroduction à Ruby
Introduction à Ruby
 
The Rails Way
The Rails WayThe Rails Way
The Rails Way
 
Intro to-rails-webperf
Intro to-rails-webperfIntro to-rails-webperf
Intro to-rails-webperf
 
Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010Código Saudável => Programador Feliz - Rs on Rails 2010
Código Saudável => Programador Feliz - Rs on Rails 2010
 
Templates, partials and layouts
Templates, partials and layoutsTemplates, partials and layouts
Templates, partials and layouts
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
 
Advanced RESTful Rails
Advanced RESTful RailsAdvanced RESTful Rails
Advanced RESTful Rails
 
Modularizing Rails Apps with Cells
Modularizing Rails Apps with CellsModularizing Rails Apps with Cells
Modularizing Rails Apps with Cells
 
Catalog display
Catalog displayCatalog display
Catalog display
 
Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...
Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...
Staying railsy - while scaling complexity or Ruby on Rails in Enterprise Soft...
 
How to disassemble one monster app into an ecosystem of 30
How to disassemble one monster app into an ecosystem of 30How to disassemble one monster app into an ecosystem of 30
How to disassemble one monster app into an ecosystem of 30
 
Rails MVC by Sergiy Koshovyi
Rails MVC by Sergiy KoshovyiRails MVC by Sergiy Koshovyi
Rails MVC by Sergiy Koshovyi
 
OSDC 2009 Rails Turtorial
OSDC 2009 Rails TurtorialOSDC 2009 Rails Turtorial
OSDC 2009 Rails Turtorial
 
What's new in Rails 4
What's new in Rails 4What's new in Rails 4
What's new in Rails 4
 
Rails 3
Rails 3Rails 3
Rails 3
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails Devs
 

More from Simon Courtois

Conseils pour un lancement Product Hunt réussi
Conseils pour un lancement Product Hunt réussiConseils pour un lancement Product Hunt réussi
Conseils pour un lancement Product Hunt réussiSimon Courtois
 
Organize your assets with Rails
Organize your assets with RailsOrganize your assets with Rails
Organize your assets with RailsSimon Courtois
 
Speed your Rails app creation with templates
Speed your Rails app creation with templatesSpeed your Rails app creation with templates
Speed your Rails app creation with templatesSimon Courtois
 
How Unidecoder Transliterates UTF-8 to ASCII
How Unidecoder Transliterates UTF-8 to ASCIIHow Unidecoder Transliterates UTF-8 to ASCII
How Unidecoder Transliterates UTF-8 to ASCIISimon Courtois
 
Fake your files - MemFs
Fake your files - MemFsFake your files - MemFs
Fake your files - MemFsSimon Courtois
 
Rails is like Burger King
Rails is like Burger KingRails is like Burger King
Rails is like Burger KingSimon Courtois
 
REST with Her (and let Her take care of the REST)
REST with Her (and let Her take care of the REST)REST with Her (and let Her take care of the REST)
REST with Her (and let Her take care of the REST)Simon Courtois
 
Vos Regexps sont fausses !
Vos Regexps sont fausses !Vos Regexps sont fausses !
Vos Regexps sont fausses !Simon Courtois
 
Pourquoi Ruby on Rails ça déchire ?
Pourquoi Ruby on Rails ça déchire ?Pourquoi Ruby on Rails ça déchire ?
Pourquoi Ruby on Rails ça déchire ?Simon Courtois
 

More from Simon Courtois (14)

Conseils pour un lancement Product Hunt réussi
Conseils pour un lancement Product Hunt réussiConseils pour un lancement Product Hunt réussi
Conseils pour un lancement Product Hunt réussi
 
Organize your assets with Rails
Organize your assets with RailsOrganize your assets with Rails
Organize your assets with Rails
 
Speed your Rails app creation with templates
Speed your Rails app creation with templatesSpeed your Rails app creation with templates
Speed your Rails app creation with templates
 
How Unidecoder Transliterates UTF-8 to ASCII
How Unidecoder Transliterates UTF-8 to ASCIIHow Unidecoder Transliterates UTF-8 to ASCII
How Unidecoder Transliterates UTF-8 to ASCII
 
Get Slim!
Get Slim!Get Slim!
Get Slim!
 
Fake your files - MemFs
Fake your files - MemFsFake your files - MemFs
Fake your files - MemFs
 
Rails is like Burger King
Rails is like Burger KingRails is like Burger King
Rails is like Burger King
 
REST with Her (and let Her take care of the REST)
REST with Her (and let Her take care of the REST)REST with Her (and let Her take care of the REST)
REST with Her (and let Her take care of the REST)
 
Ruby and DCI
Ruby and DCIRuby and DCI
Ruby and DCI
 
Mustdown
MustdownMustdown
Mustdown
 
Vos Regexps sont fausses !
Vos Regexps sont fausses !Vos Regexps sont fausses !
Vos Regexps sont fausses !
 
Ariane
ArianeAriane
Ariane
 
Pourquoi Ruby on Rails ça déchire ?
Pourquoi Ruby on Rails ça déchire ?Pourquoi Ruby on Rails ça déchire ?
Pourquoi Ruby on Rails ça déchire ?
 
Commander
CommanderCommander
Commander
 

Recently uploaded

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 

Recently uploaded (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 

Cells

  • 2. Problématique Comment partager un widget entre les pages du site ? github: apotonick/cells
  • 3. Solution à l’ancienne # app/controllers/application_controller.rb class ApplicationController < ActionController::Base before_filter :set_shopping_cart private def set_shopping_cart @shopping_cart = ShoppingCart.for_user(current_user) end end # app/views/layouts/application.html.erb <%= render 'shared/shopping_cart', shopping_cart: @shopping_cart %> # app/views/shared/_shopping_cart.html.erb <% if @shopping_cart %> # shopping cart rendering <% end %> github: apotonick/cells
  • 4. Solution avec Cells # app/views/layouts/application.html.erb <%= render_cell :shopping_cart, :display, user: current_user %> # app/cells/shopping_cart_cell.rb class ShoppingCartCell < Cell::Rails def display(opts) @shopping_cart = ShoppingCart.for_user(opts[:user]) render end end # app/cells/shopping_cart/display.html.erb <% if @shopping_cart %> # shopping cart rendering <% end %> github: apotonick/cells
  • 5. Avantages Séparation des responsabilités Meilleure organisation du code app/ cells/ shopping_cart/ display.html.erb shopping_cart.rb github: apotonick/cells
  • 6. Aller plus loin - actions # app/cells/shopping_cart_cell.rb class ShoppingCartCell < Cell::Rails def display(opts) @shopping_cart = ShoppingCart.for_user(opts[:user]) render end def count(opts) shopping_cart = ShoppingCart.for_user(opts[:user]) @items_count = shopping_cart.items_count render end end # app/views/layouts/application.html.erb <%= render_cell :shopping_cart, :display, user: current_user %> <%= render_cell :shopping_cart, :count, user: current_user %> github: apotonick/cells
  • 7. Aller plus loin - cache # app/cells/shopping_cart_cell.rb class ShoppingCartCell < Cell::Rails cache :display, expires_in: 10.minutes def display(opts) # ... end end github: apotonick/cells
  • 8. Aller plus loin - cache # app/cells/shopping_cart_cell.rb class ShoppingCartCell < Cell::Rails cache :display do |cell, opts| opts[:user] end def display(opts) # ... end end github: apotonick/cells
  • 9. Aller plus loin - helpers # app/cells/shopping_cart_cell.rb class ShoppingCartCell < Cell::Rails helper MyAwesomeHelper def display(opts) @shopping_cart = ShoppingCart.for_user(opts[:user]) render end end # app/cells/shopping_cart/display.html.erb <%= do_something_awesome %> github: apotonick/cells
  • 10. Installation gem ‘cells’ $ rails generate cell shopping_cart display http://github.com/apotonick/cells github: apotonick/cells