{"id":7531,"date":"2019-11-25T23:46:23","date_gmt":"2019-11-25T14:46:23","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=7531"},"modified":"2020-11-29T20:29:06","modified_gmt":"2020-11-29T11:29:06","slug":"%e3%80%90ruby-on-rails%e3%80%91%e3%83%95%e3%82%a9%e3%83%bc%e3%83%a0%e9%96%a2%e9%80%a3%e3%81%ae%e3%83%93%e3%83%a5%e3%83%bc%e3%83%98%e3%83%ab%e3%83%91%e3%83%bc","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=7531","title":{"rendered":"\u3010Ruby on Rails\u3011\u30d5\u30a9\u30fc\u30e0\u95a2\u9023\u306e\u30d3\u30e5\u30fc\u30d8\u30eb\u30d1\u30fc(form_with\u7b49\uff09"},"content":{"rendered":"<h2>\u30d5\u30a9\u30fc\u30e0\u95a2\u9023\u30d3\u30e5\u30fc\u30d8\u30eb\u30d1\u30fc<\/h2>\n<p>&lt;form&gt;\u8981\u7d20\u3092\u751f\u6210\u3059\u308b\u305f\u3081\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002\u30e2\u30c7\u30eb\u3068\u30d5\u30a9\u30fc\u30e0\u306f\u3001<span style=\"color: #ff0000;\"><strong>\u30d5\u30a9\u30fc\u30e0\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u30e2\u30c7\u30eb\u306e\u5c5e\u6027\u306b\u5bfe\u5fdc\u3059\u308b\u3068\u3044\u3046\u9762\u3067\u69cb\u9020\u304c\u4f3c\u3066\u3044\u308b<\/strong><\/span>\u305f\u3081\u306b\u30d5\u30a9\u30fc\u30e0\u95a2\u9023\u306e\u30d3\u30e5\u30fc\u30d8\u30eb\u30d1\u30fc\u3092\u4f7f\u3046\u3068\u54c1\u8cea\u306e\u9ad8\u3044\u30b3\u30fc\u30c9\u3092\u7c21\u6f54\u306b\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h3>form_with(5.1\u3067\u5b9f\u88c5\u3055\u308c\u305f\uff09<\/h3>\n<p>Rails5.1\u4ee5\u964d\u3067\u63a8\u5968\u3055\u308c\u3066\u3044\u308b\u30d3\u30e5\u30fc\u30d8\u30eb\u30d1\u30fc\u3067\u3059\u3002form_tag\u3084form_for\u306e\u6a5f\u80fd\u3092\u7d71\u5408\u3057\u305f\u3082\u306e\u306a\u306e\u3067\u3053\u3061\u3089\u3092\u4f7f\u3046\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>form_tag(5.1\u4ee5\u964d\u306f\u975e\u63a8\u5968\uff09<\/h3>\n<p><span style=\"color: #ff0000;\"><strong>\u30e2\u30c7\u30eb\u306b\u95a2\u9023\u3057\u306a\u3044<\/strong><\/span>\u6c4e\u7528\u7684\u306a\u30d5\u30a9\u30fc\u30e0\u3092\u751f\u6210\u30015.1\u4ee5\u964d\u3067\u306f\u975e\u63a8\u5968\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h3>form_for(5.1\u4ee5\u964d\u306f\u975e\u63a8\u5968\uff09<\/h3>\n<p><span style=\"color: #ff0000;\"><strong>\u7279\u5b9a\u306e\u30e2\u30c7\u30eb\u306b\u7279\u5316<\/strong><\/span>\u3057\u305f\u30d5\u30a9\u30fc\u30e0\u3092\u751f\u6210\u30015.1\u4ee5\u964d\u3067\u306f\u975e\u63a8\u5968\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<h2>form_with\u306e\u4ed5\u69d8\u306b\u3064\u3044\u3066<\/h2>\n<h3>model:<\/h3>\n<p>\u300cmodel: @\u30e2\u30c7\u30eb\u540d\u300d\u3068\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u30e2\u30c7\u30eb\u3068\u30d5\u30a9\u30fc\u30e0\u3092\u5bfe\u5fdc\u3065\u3051\u307e\u3059\u3002\u6307\u5b9a\u3067\u304d\u308b\u306e\u306f\u300cActiveRecord::Base\u300d\u3092\u7d99\u627f\u3057\u305f\u30af\u30e9\u30b9\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u304b\u3001\u300c\u975eActiveRecord\u300d\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\uff08\u30d5\u30a9\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\uff09\u306e\u3069\u3061\u3089\u304b\u306b\u306a\u308a\u307e\u3059\u3002\u30d5\u30a9\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u3064\u3044\u3066\u306f\u4e0b\u8a18\u306e\u8a18\u4e8b\u3067\u89e3\u8aac\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<blockquote class=\"wp-embedded-content\" data-secret=\"hHHwV1u7dV\"><p><a href=\"http:\/\/www.code-magagine.com\/?p=12312\">\u3010Ruby on Rails\u3011\u300c\u30d5\u30a9\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u300d\u306b\u3064\u3044\u3066<\/a><\/p><\/blockquote>\n<p><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" src=\"http:\/\/www.code-magagine.com\/?p=12312&#038;embed=true#?secret=hHHwV1u7dV\" data-secret=\"hHHwV1u7dV\" width=\"500\" height=\"282\" title=\"&#8220;\u3010Ruby on Rails\u3011\u300c\u30d5\u30a9\u30fc\u30e0\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u300d\u306b\u3064\u3044\u3066&#8221; &#8212; \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30de\u30ac\u30b8\u30f3\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n<h4>\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u95a2\u4fc2\u306b\u3042\u308b\u30e2\u30c7\u30eb\u3092\u6307\u5b9a\u3057\u305f\u3044\u5834\u5408<\/h4>\n<p>\u89aa\u30e2\u30c7\u30eb\u306b\u7d10\u3065\u304f\u3001\u5b50\u30e2\u30c7\u30eb\u3092form\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3068\u3057\u3066\u6307\u5b9a\u3057\u305f\u3044\u5834\u5408\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306b\u914d\u5217\u3092\u6307\u5b9a\u3057\u3066\u5bfe\u5fdc\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">&lt;%= form_with model: [@\u89aa\u30e2\u30c7\u30eb, @\u5b50\u30e2\u30c7\u30eb],local: true do |f| %&gt;\r\n&lt;% end\u3000%&gt;<\/pre>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u5074\u3067\u306f\u4e0b\u8a18\u306e\u3088\u3046\u306a\u611f\u3058\u3067\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<pre class=\"lang:default decode:true \">def \u30e1\u30bd\u30c3\u30c9\u540d\r\n    @\u89aa\u30e2\u30c7\u30eb\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570 = \u89aa\u30e2\u30c7\u30eb.find(params[:id])\r\n    @\u5b50\u30e2\u30c7\u30eb\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570 = \u5b50\u30e2\u30c7\u30eb.new\r\nend\r\n<\/pre>\n<h3>url:<\/h3>\n<p>\u9077\u79fb\u5148\u306eURL\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h3><span style=\"font-family: arial, helvetica, sans-serif;\">local:<\/span><\/h3>\n<p>\u975e\u540c\u671f\u901a\u4fe1\u3092\u6709\u52b9\u5316\u3059\u308b\u304b\u3069\u3046\u304b\u3067\u3059\u3002true\u306b\u3057\u305f\u3089\u975e\u540c\u671f\u3092\u4f7f\u308f\u306a\u3044\u3001false\u306b\u3059\u308b\u3068\u975e\u540c\u671f\u901a\u4fe1\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<h2>\u30d5\u30a9\u30fc\u30e0\u306e\u8981\u7d20\u95a2\u9023\uff08\u30d5\u30a3\u30fc\u30eb\u30c9\u7cfb\uff09\u30d3\u30e5\u30fc\u30d8\u30eb\u30d1\u30fc<\/h2>\n<p><span style=\"color: #ff0000;\"><strong>3\u3064\u306e\u30d8\u30eb\u30d1\u30fc\u306e\u4e2d\u3067\u5229\u7528\u983b\u5ea6\u304c\u9ad8\u3044<\/strong><\/span>\u3067\u3059\u3002\u300cf\u300d\u3068\u3044\u3046\u306e\u306f\u30d6\u30ed\u30c3\u30af\u5f15\u6570\u306e\u3053\u3068\u3067\u3001\u300cform_with\u30e1\u30bd\u30c3\u30c9\u300d\u306e\u300c\u301cdo |f|\u300d\u3068\u6307\u5b9a\u3057\u3066\u3044\u308b\u7b87\u6240\u3067\u6307\u5b9a\u3057\u3066\u3044\u308b\u5f15\u6570\u306e\u3053\u3068\u3067\u3059\u3002\uff08\u5225\u306bf\u3058\u3083\u306a\u304f\u3066\u3082\u306a\u3093\u3067\u3082\u69cb\u3044\u307e\u305b\u3093\u304cf\u3068\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u3088\u3046\u3067\u3059\u3002\uff09\u3053\u306ef\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067<span style=\"color: #ff0000;\"><strong>\u30e2\u30c7\u30eb\u306b\u5bfe\u5fdc\u3059\u308b\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u51fa\u529b\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/strong><\/span><\/p>\n<h3>f.label<\/h3>\n<p>\u30e9\u30d9\u30eb\u8981\u7d20\u3092\u51fa\u529b\u3059\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true \">f.label :\u30ab\u30e9\u30e0\u540d<\/pre>\n<h3>f.text_field<\/h3>\n<p>\u5165\u529b\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u4f5c\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true\">f.text_field :\u30ab\u30e9\u30e0\u540d<\/pre>\n<h3>f.text_area<\/h3>\n<p>\u8a73\u7d30\u306a\u5165\u529b\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u4f5c\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true\">f.text_area :\u30ab\u30e9\u30e0\u540d<\/pre>\n<h3>f.hidden_field<\/h3>\n<p>hidden\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h3>f.submit<\/h3>\n<p>submit\u30d8\u30eb\u30d1\u30fc\u3092\u547c\u3076\u3002<\/p>\n<h3>f.file_field<\/h3>\n<h3>f.check_box<\/h3>\n<h3>f.radio_button<\/h3>\n<h3>f.select<\/h3>\n<h3>f.collection_select<\/h3>\n<h3>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u60c5\u5831\u3092\u5143\u306b\u9078\u629e\u80a2\u3092\u751f\u6210\u3059\u308b\u3002<\/h3>\n<h3>f.grouped_collection_select<\/h3>\n<p>\u9078\u629e\u30dc\u30c3\u30af\u30b9\u306e\u9078\u629e\u80a2\u3092\u30b0\u30eb\u30fc\u30d7\u5316\u3059\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u30d5\u30a9\u30fc\u30e0\u95a2\u9023\u30d3\u30e5\u30fc\u30d8\u30eb\u30d1\u30fc &lt;form&gt;\u8981\u7d20\u3092\u751f\u6210\u3059\u308b\u305f\u3081\u306e\u30e1\u30bd\u30c3\u30c9\u3067\u3059\u3002\u30e2\u30c7\u30eb\u3068\u30d5\u30a9\u30fc\u30e0\u306f\u3001\u30d5\u30a9\u30fc\u30e0\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u304c\u30e2\u30c7\u30eb\u306e\u5c5e\u6027\u306b\u5bfe\u5fdc\u3059\u308b\u3068\u3044\u3046\u9762\u3067\u69cb\u9020\u304c\u4f3c\u3066\u3044\u308b\u305f\u3081\u306b\u30d5\u30a9\u30fc\u30e0\u95a2\u9023\u306e\u30d3\u30e5\u30fc\u30d8\u30eb\u30d1\u30fc\u3092\u4f7f\u3046\u3068\u54c1\u8cea [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[36],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/7531"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7531"}],"version-history":[{"count":26,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/7531\/revisions"}],"predecessor-version":[{"id":12318,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/7531\/revisions\/12318"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7531"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}