Kaigi on Rails 2023 ã§Turbolinkså«ãã«Turboãé£ãããç»å£ããã¾ãã #kaigionrails
å
æã®å¤§éªRubyä¼è°03, æ¾æ±Rubyä¼è°10 ããç¶ã3é£ç¶ç»å£ã®æçµåï¼
ãªãã¨ãKaigi on Rails 2023ãã§ç»å£ããã¦ããã ãã¾ããã
ãTurbolinksã¢ã¬ã«ã®ã¼æ£è ã«æ§ããTurbo & Stimulusã§ã®æçå®è£ è¡ã www.youtube.com
ã¹ã©ã¤ãã¯ãã¡ãã§ãã
ææ³
å»å¹´ã®Kaigi on Railsã«æåºãããããã¼ã¶ã«ã¯è½é¸ãã¦ãã¾ã£ãã®ã§ãä»åã¯2åç®ã®ææ¦ã§ããã
ã¨ã¯ããä»å¹´ã¯100件以ä¸ã®CFPãæåºããã¦ããã®ã§ãã¾ãéãããããªãâ¦â¦ããããã«æã£ã¦ãã¾ãããããªãã¨æ¡æããã ããã®ã§ããããããâ¦ããããâ¦ãã¨ããæ°æã¡ã«ãªã£ã¦ãã¾ãã
ã¾ããHotwireæ ã®ç»å£ã3ã¤ããã£ãã®ãé©ãã§ããããä¸ã®ä¸ã®ããã³ãã¨ã³ãã®ä¸»æµã§ã¯ããã¾ããããæå¤ã¨å¤§ããªæ³¢ãæ¥ã¦ããã®ã§ããããã
æè¿ã¯ htmx ã話é¡ã«ãªã£ã¦ãã¾ããããç¾ä»£ã®ããã³ãã¨ã³ãããã©ããæ°ã¨ãã¦ã¯ä»å¾ã使ããã¦ããã¨ãããªã¨æãã¾ãã
åå è
400人ã¨ãããã«ãã®ä¼ã§ããããç»å£è
å´ã¨ãã¦ã¯ç¹ã«å°ããã¨ããªãçºè¡¨ãããã¨ãã§ãã¾ããã
ä¼å ´ãåå¨ãã¦ããã®å ´ã®ä¼æ©æéãæ親ä¼ã§ç´æ¥è³ªåããããããããçºçããã®ã§ãç»å£å
容以ä¸ã®åç©«ãããã¤ãã³ãã§ãããã
ã³ãã¥ã®éã®è ã§ä¸ã¤é°ã®è ãªã®ã§ãåå¼·ä¼ãªã©ã§ã¯äº¤æµã§ããªããã¨ãå¤ãã®ã§ãããç»å£ãã¦ããã¨çºè¡¨å 容ã®è©±ãã§ããã®ã§æå¼·ã§ããã ããããä»ã®æ¹ã®ç»å£å 容ãªã©ã«ãç¹ãã¦ãããã®ã§ãä»åã¯è©±ã®ãã¿ã«å°ããã¨ã¯ç¡ãã£ãããã«æãã¾ãã
é°ã®è ãã¡ããç»å£ãããã
ç»å£ã®ãµãããã
ã»ãã·ã§ã³å½æ¥ã¯ãä¼å ´æºå¸ & ãµãã©ã¤ãä¼å ´ã®æ¹ã«ãæ¡å ãã¨ãªã£ã¦ãããã¾ãã«æºå¡å¾¡ç¤¼ã¨ããå¬ããç¶æ³ã§ããããªã³ã©ã¤ã³è¦è´ãå«ããã¨ããªãã®äººæ°ã«ãªãããã§ãããã»ãã·ã§ã³ã«ãè¶ãããã ãèª ã«ãããã¨ããããã¾ããã
ç»å£å¾ããé¢ç½ãã£ããã¨ãã声ãããããé ããã®ã§ãå¿ã®ä¸ã§å°èºããã¦ããã¾ãã
大ããªå¤±æããªãç¡äºã«ç»å£ãçµããããã®ã§ãåå¿é²ãããã¦ãã£ãããµãããããæ®ãã¦ããã¾ãããã
使ç¨æè¡
Hotwireã®å®ç¨ä¾
15åæ ã ã£ãããHotwireå ¥éããã£ã¦ããæéã¯ãªããTurboãStimulusã使ãã¨å¬ããã±ã¼ã¹ããããªãç´¹ä»&å®è·µãã¾ããã
Turboã¯æ©è½ã®1ã¤ã¨ãã¦bodyã®å ¨ä½ã¾ãã¯ä¸é¨ã®è¦ç´ ãå·®ãæ¿ããå¦çãæä¾ãã¦ãããããããµã¼ãã¼ãµã¤ãã§å®¹æã«å®è£ ãããã¨ãã§ãã¾ãã
ã¢ã¼ãã«ãã¤ã¢ãã°ã®è¡¨ç¤ºãã以ä¸ã®ããã«Railsã®viewãããã¤ã¢ãã°ã®HTMLãè¿å´ãã¦ããã ãã§ãã
= turbo_stream.update "modal" do .modal.is-active .modal-background .modal-content .box .block p | ãã®å 容ã§åãåããã¦ããããã§ããï¼ .block = form_with url: inquiries_path, model: @inquiry do |f| = f.hidden_field :email = f.hidden_field :subject = f.hidden_field :body (以éã¯çç¥)
ã¾ããHTMLã®ä¸é¨ãå·®ãæ¿ããã¨ãããã¨ã¯ãä»ã®è¦ç´ ãå¤æ´ããä¿è·ãããã¨ãããã¨ã§ãããã¾ãã
ãå¤æ´ãå¿ è¦ãªé¨åã®ã¿renderããä¿æãããè¦ç´ ã¯renderããªããã¨ããé¸æè¢ãåããã®ãå¬ããæã§ããã
ããã§ã¨ã©ã¼è¡¨ç¤ºã®éãªã©ã«ããå®è£
ããããã¦ã¼ã¶ã¼å
¥åå¤ãåç¾ãããã©ã¼ã ãrenderãããã¨ããé¢åãããå¦çãå
¨æ¤å»ãããã¨ãå¯è½ã§ãã
ãã¹ã¯ã¼ããã©ã¼ã ã®å¤ãªã©ã¯å¹³æã§HTMLã«åãè¾¼ãã§è¿ãå¿
è¦ãããã¾ãããããã»ãã¥ãªãã£çã«ãããã¦ãããæ¹ãããã§ãããã
ãããã£ã使ãæ¹ãé§ä½¿ãã¦ãæçå®è£ ã§ãããï¼ãã¨ãããããªå 容ã®ç»å£ããã¾ããã
Turboãé£ããå«ããã¦ç¡å¹åãã人ãæ¸ãã°ããã§ãããã
Hotwireãå®ç¨Tipsã®è§£èª¬
Hotwire称è³ã°ããã§ã¯ä¸èª å®ã ããã¨èããã¡ãªãã/ãã¡ãªããã®ç´¹ä»ããã¾ããã
- ã¡ãªãã
- Javascriptå®è£ ã®è² è·ãæå°éã«ã§ãã
- ãµã¼ããµã¤ãã«è³ç£ãéç´ã§ãã
- ãã¡ãªãã
- æ¯åãµã¼ãã¨éä¿¡ãã¦DOMæä½ããããéä¿¡ãªãã§DOMæä½ããããå ´åã«å¼±ã
Hotwireã«ã¯ä¸è¨ã®ç¹å¾´ãããããªãã¨å人çã«ã¯èãã¦ãã¾ãã
ãã¨ã¯ç´°ãããããã©ããã¨å¯¾å¦æ³ãããã¤ã解説ãæã»ã©ã§ã¯ãªãã¨ã¯è¨ããiOSã®Mobile Safari対å¿ã¯å¼·æµã§ããã
Mobile Safariã¯ãããã¢ãããç¡æã§ãããã¯ããã®ãããããã¦ã¼ã¶ã¼ã«éç¥ããã
æ¯åº¦ããªãã¿ã®æ¥½ãããã¢
ä»å¹´ã®ç»å£ã¯å ¨ã¦åä½ãããã¢ãç¨æãã¦å£ä¸ã§åããã¦ãã¾ããä»åã®Kaigi on Railsã§ããå®éã«Hotwireãåãããéã®æåãã¹ã¯ãªã¼ã³ä¸ã«æ ãã¦è§£èª¬ãã¦ãã¾ãã
ä»åã¯ããã¢ãåãããªããããã¹ãã§è£è¶³ãããåãããããã®ã§ã¯â¦ï¼ãã¨ç´åã«éãã¦ãã¾ããã¹ã©ã¤ãã¨ãã¢ç»é¢ãåæã«ã¹ã¯ãªã¼ã³ã«æå½±ããæ¹å¼ãéçº/æ¡ç¨ãã¾ããããã2é±éæ©ãæãã¤ãã¦ãããã¹ã©ã¤ãä½ãç´ããã«æ¸ãã ã®ã«ãªãã
ããªãèªç¶ãªåºæ¥ã ã£ãããã§ãã¹ã©ã¤ãä¸ã®ãã¢åç»ãã¨æã£ã¦ãã人ãå± ãããã§ãããã®è¾ºã®æè¡ããã¤ãæ¸ãæ®ãããæã§ããã
ãã¢ã¨ãããã®ã¯ãä½æ ãæ¬çªã§åããªããã®ã®ããå¤ç¨ããã®ã¯é常ã«ãªã¹ãã¼ãªã®ã§ãããæ¯åãã¯ããæã£ã¦ãã¢æ«é²ãæ¢è¡ãã¦ãã¾ãã
ããããªããä»å¹´ã¯ãªãã¨ãã¼ãã¹ã§ãããã£ããã
ã³ã¼ã« & ã¬ã¹ãã³ã¹
ããã£ãããªãã©ã¤ã³ç»å£ã ããã³ã¼ã¬ã¹ã¨ããã£ã¦ã¿ã¦ãããããããã¨ãã欲ãåºã¦ããã®ã§ããã¬ã¼ã³ã®ã¤ãã¿ã¨ãã¦å®æ½ãã¾ããã
- ãTurbolinksãç¥ã£ã¦ã人ãï¼ãâ ððððð
- ãTurbolinksã使ã£ã¦ã人ãï¼ãâ ðâ¦â¦â¦
ãªãã¹ãåããããããããªè©±ãæ¹ã¯å¿ããã¾ããããäºæ³ä»¥ä¸ã«ããããª100%決ã¾ã£ã¦ãã¾ã£ãã®ã§ããã¯ãªãã¦ãã¾ãã
å®éã®æã¯Turbolinks使ã£ã¦ãã人ãå± ãã¯ãã§ãããã¿ããªæµããèªãã®ããã¾ããã
è´è¡ããã®ã¬ã¹ãã³ã¹ãåãåããã®ã¯ãªãã©ã¤ã³ç»å£ã®è¯ãã¨ããã§ããã
ãããã«
ã¨ãããã¨ã§æ¯ãè¿ãã¯ä»¥ä¸ï¼
ãã«ã¿ã¤ã ã§ä»äºãã¤ã¤2ã¶æã§3ç»å£ã¯ç¡è¶ã ã£ãâ¦â¦
ä½åã®éçãªã®ã§ãã°ããã¯ã®ãã³ãæ®ãããã