~/talk

Encapsulating Views

Talkat RailsConf 2020 CE · 2020-05-04..05-05· [ruby-on-rails, component-design]
slides:none on file

Rails views compile into methods on ActionView::Base so templates share instance variables and execute in a global scope, which makes unit testing and reasoning hard; GitHub builds ViewComponent to attach compiled templates to component objects, enabling per-component encapsulation, precompilation at boot to avoid per-process compile pauses, and fast unit tests (views compile into methods, components unit tests ~20ms vs controller ~1.5s). At scale—about 4,400 views and 3,000 partials—112 components cover ~550 usages and Rails 6.1 adds native support for third‑party component libraries.

AI-written summary · about

  1. 0:00Start
  2. 3:45600 controllers
  3. 8:15Ecosystem Survey
  4. 8:53Draper & Cells
  5. 9:15Testing views
  6. 10:09View objects
  7. 12:09interface
  8. 17:46Views are methods
  9. 18:38Global scope
  10. 19:13Unit Testing
  11. 19:36Decorators, Presenters, Components
  12. 20:03one context for all views
  13. 26:10component gems
  14. 26:48Performance
  15. 28:59Levels of abstraction
  16. 29:473,000 partials
  17. 32:20Resiliency
  18. 32:35Exposing complexity
  19. 33:35Consistency
  20. 36:24Examples
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.