form_tagã®ãªãã·ã§ã³ã®ä»ãæ¹ã§æ¯åè¿·ããã¨ãããRubyãããã
é¡ã®éãã
æ¯åæ¯åã¨ã©ã¼åããã¦è
¹ãç«ã¤ã®ã§ã¡ã¢ã
ä½ããåç´ãªè©±ã§ãform_tagã¯å¼æ°ãå¿
ã2ã¤ã¨ãããã¨ãè¦ãã¦ããã°ãããããã
ã¤ã¾ãã
<%= form_tag('/estates/search', {method: :get, id: 'search-form'}) do %>
ãããããã¨ï¼
第ä¸å¼æ°ã«ã¢ã¯ã·ã§ã³ãã第äºå¼æ°ã«ãã®ä»ã®ãªãã·ã§ã³ãå
¨ã¦ã¶ã¡è¾¼ãã§ããã
ãã ãã®form_tagã®åããã¥ããã¨ããã¯ã
<%= form_tag('/estates/search', method: :get, id: 'search-form') do %>
ã§ãéã£ã¦ãã¾ãã¨ããã
ã¯ã£ããè¨ãã¾ãã¨ããèªåã¯Rubyã大å«ãã§ãã
TMTOWTDIã¨ãç³é£ããã£ã¦æãããã§ãã
Perlæ¸ã人ã«ã¯å¤§å¤ç³ã訳ãªãã§ããâ¦â¦ã
ããã¯ããä¿¡ä»°ã®åé¡ã§ããã©ãããã°ã©ãã³ã°ã«ããã¦ããæ¹ãè¤æ°ãããã¨ã®å©ç¹ãèªåã¯æãã¾ããã
ããæ¹ã¯ã²ã¨ã¤ãThere's one way.ããã¹ãã§ãã
ç¥ã«èªã£ã¦ã
ç§ãæè¿ã®è¥è
ã ããæ¥ã«ãã¬ã ããããã§ã¯ããã¾ããã
å¾è
ã®form_tagã£ã¦åè¦ã ã£ããã©ãèãã¦ãããããã§ãããã
å¼æ°3ã¤ããããããå¯å¤å¼æ°ãªã®ããï¼ã¨ãæãã§ããæ®éã
å®ã¯Rubyã£ã¦æå¾ã®å¼æ°ãããã·ã¥ã ã£ããæ³¢æ¬å¼§ãçç¥å¯è½ããããã§ããã
ãããã解éããããããã ãããå¾è
ã®è¨è¿°ã§ãå
é¨çã«ã¯å¼æ°ã2ã¤ã®ã¡ã½ããå¼ã³åºãã ã¨ãRubyã¯è¨ãããã§ãã
ãããæ³¢æ¬å¼§çç¥ããæå³ããã¾ããï¼
ã©ãèãã¦ãæ³¢æ¬å¼§ãã£ãã»ããåãããããã§ããï¼
ã©ã£ã¡ã§ããããã¼ãããªããã ãã©ã£ã¡ãã«ãããã¨ãããã¡ããã¨ã«ãã³ã¯çããã
ã¡ã½ããå¼ã³åºãã§ã«ãã³ã®çç¥ãå¯è½ãªãã¨ãèªåçã«ã¯é常ã«æ°ã«å
¥ãã¾ããã
ãã®ã«ãã³ã®çç¥ã«ããã¿ã¤ãæ°ã®æ¸å°ã§å¾ããã®ããã¾ãã«ãå¾®å°ãããçã«ã失ããã®ã¯å±±ã»ã©ããããã«æãããã§ãã
以ä¸è¨èªã¸ã®ã¤ã©ã¤ã©ã§ããã¨ãã
åè
form_tag - リファレンス - Railsドキュメント
Railsのform_tagで生成されるHTML - maeharinの日記
Railsを触る際知っていると便利なRubyの基礎 [ブロックとかシンボルとか] - Qiita