{"id":602,"date":"2018-05-27T21:18:31","date_gmt":"2018-05-27T12:18:31","guid":{"rendered":"https:\/\/yuis-programming.com\/?p=602"},"modified":"2018-05-01T01:18:40","modified_gmt":"2018-04-30T16:18:40","slug":"rails-%e3%83%ab%e3%83%bc%e3%83%86%e3%82%a3%e3%83%b3%e3%82%b0%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/yuis-programming.com\/?p=602","title":{"rendered":"Rails \u30eb\u30fc\u30c6\u30a3\u30f3\u30b0\u306b\u3064\u3044\u3066"},"content":{"rendered":"<p><code>rails c<\/code>\u3092\u3059\u308b\u3068\u3001 Prefix; Verb; URI Pattern; Controller#Action; \u3068\u5206\u304b\u308c\u3066\u8868\u793a\u3055\u308c\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001<br \/>\n\u3053\u308c\u3089\u305d\u308c\u305e\u308c\u610f\u5473\u3059\u308b\u3082\u306e\u3084\u3001\u5b9a\u7fa9\u306e\u4ed5\u65b9\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<p>get &#8216;userinfo\/show\/:here\/:dist&#8217; => &#8216;userinfo#show&#8217;,as:&#8217;userinfo_show&#8217;<\/p>\n<p><code>routes.rb<\/code>\u304b\u3089\u3001\u3053\u306e\u884c\u3092\u4f8b\u306b\u3068\u3063\u3066\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<p>\u6700\u521d\u306e<code>get<\/code>\u3084<code>post<\/code>\u3001\u4ed6\u306b\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u3053\u308c\u3089\u304cVerb<br \/>\nget\u3084post\u306b\u7d9a\u3044\u3066\u6307\u5b9a\u3057\u3066\u3044\u308b\u30d1\u30b9\u304c\u3001URI pattern<br \/>\n<code>:<\/code>or<code>to<\/code>or<code>=&gt;<\/code>\u3067\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u306e\u304c\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u306e\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u793a\u3059\u3001Controller#Action<br \/>\n\u6700\u5f8c\u306b\u3001<code>as:<\/code>\u3067\u5b9a\u7fa9\u3057\u3066\u3044\u308b\u306e\u304c\u3001Prefix<\/p>\n<p>\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>get\u3084post\u306b\u95a2\u3057\u3066\u306f\u308f\u304b\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u7c21\u5358\u306b\u8a00\u3048\u3070\u3001get\u304c\u6307\u5b9a\u3055\u308c\u3066\u3044\u308c\u3070\u3001\u305d\u306eURL\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u3082\u3063\u3068\u3082\u3001Rails\u306e\u5834\u5408\u306f\u3001\u305d\u306eget\u306eURL\u306b\u57fa\u3065\u3044\u305fhtml.erb\u304c\u5b58\u5728\u3057\u306a\u3044\u3068\u3001\u30a8\u30e9\u30fc\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3059\u304c\u3002<br \/>\npost\u306f\u3001\u30e6\u30fc\u30b6\u30fc\u304c\u30d5\u30a9\u30fc\u30e0\u306a\u3069\u306b\u5165\u529b\u3057\u305f\u30c7\u30fc\u30bf\u3092\u3001post\u3067\u6307\u5b9a\u3057\u305f\u4ed6\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u9001\u4fe1\u3059\u308b\u5f79\u5272\u3067\u3059\u3002<br \/>\n\u4ed6\u306b\u3082put\u3068\u304b\u3042\u308a\u307e\u3059\u304c\u3001\u96e3\u3057\u3044\u306e\u3067\u7701\u7565\u3002<\/p>\n<p><code>to<\/code>\u3067\u6307\u5b9a\u3059\u308b\u306e\u304c\u3001\u30a2\u30af\u30b7\u30e7\u30f3\u3067\u3059\u3002\u3053\u3053\u3067\u306f\u3001userinfo_controller.rb\u306edef\u3067\u5b9a\u7fa9\u3055\u308c\u305f\u3001show\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u305d\u306eshow\u30a2\u30af\u30b7\u30e7\u30f3\u306b\u66f8\u3044\u3066\u3042\u308bRuby\u30b3\u30fc\u30c9\u304c\u3001\u6700\u7d42\u7684\u306b\u30da\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b\u307e\u3067\u306b\u51e6\u7406\u3055\u308c\u308b\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>prefix\u3067\u3059\u304c\u3001\u3053\u308c\u306f\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u306e\u30e6\u30fc\u30b6\u30fc\u5b9a\u7fa9\u3001\u3068\u3067\u3082\u8a00\u3048\u3070\u826f\u3044\u306e\u3067\u3057\u3087\u3046\u304b\u3002<br \/>\n\u3053\u306ePrefix\u306b\u3001<code>_path<\/code>\u3092\u3064\u3051\u308c\u3070\u3001Rails\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30d5\u30a9\u30eb\u30c0\u306e\u3069\u3053\u304b\u3089\u3067\u3082\u3001\u7279\u5b9a\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u53c2\u7167\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u4f8b\u3048\u3070\u3001<\/p>\n<pre><code>&lt;%= form_for(@userinfo , url: dev\/update) do |f| %&gt;\n  &lt;%= f.text_area :name %&gt;\n  &lt;%= f.submit %&gt;\n&lt;% end %&gt;\n<\/code><\/pre>\n<p>\u3068\u66f8\u304f\u306e\u3068\u3001<\/p>\n<pre><code>&lt;%= form_for(@userinfo , url: dev_update_path) do |f| %&gt;\n  &lt;%= f.text_area :name %&gt;\n  &lt;%= f.submit %&gt;\n&lt;% end %&gt;\n<\/code><\/pre>\n<p>\u3068\u66f8\u304f\u306e\u306f\u3001\u540c\u3058\u3067\u3059\u3002<\/p>\n<p>\u53cc\u65b9\u3068\u3082\u3001<code>url:<\/code>\u3067\u540c\u3058\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>rails c\u3092\u3059\u308b\u3068\u3001 Prefix; Verb; URI Pattern; Controller#Acti [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"acf":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8Rxwo-9I","_links":{"self":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/602"}],"collection":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=602"}],"version-history":[{"count":1,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/602\/revisions"}],"predecessor-version":[{"id":603,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/602\/revisions\/603"}],"wp:attachment":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}