{"id":64345,"date":"2021-08-01T08:08:09","date_gmt":"1970-01-01T00:00:00","guid":{"rendered":"https:\/\/www.sejuku.net\/blog\/?p=64345"},"modified":"2024-05-06T11:49:52","modified_gmt":"2024-05-06T02:49:52","slug":"%e3%80%90ruby%e5%85%a5%e9%96%80%e3%80%91active-record%ef%bc%88o-r%e3%83%9e%e3%83%83%e3%83%91%e3%83%bc%ef%bc%89%e3%81%a7attributes%e3%82%92%e6%89%b1%e3%81%8a%e3%81%86","status":"publish","type":"post","link":"https:\/\/www.sejuku.net\/blog\/64345","title":{"rendered":"\u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u4eca\u65e5\u306f\u3001<span style=\"color: #339966;\"><strong>Ruby on Rails<\/strong><\/span>\uff08\u4ee5\u964d\u3001<span style=\"color: #339966;\"><strong>Rails<\/strong><\/span>\uff09\u306e<span style=\"color: #54a870;\"><strong>Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09<\/strong><\/span>\u3067\u3001<span style=\"color: #54a870;\"><strong>attributes<\/strong><\/span>\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5\u3092\u3044\u304f\u3064\u304b\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<div style=\"padding: 10px 5px 10px 20px; margin-bottom: 20px; border: 2px solid #ffe4e2;\">\u30fbattribute\u3084assign_attributes\u3067\u66f4\u65b0\u3057\u305f\u30c7\u30fc\u30bf\u304c\u3001\u5143\u306b\u623b\u3063\u3066\u3057\u307e\u3046\u3093\u3060\u3051\u3069\u2026<br \/>\n\u30fbhas_many\u306e\u95a2\u4fc2\u3092\u6301\u3064\u5165\u308c\u5b50\u306e\u30c7\u30fc\u30bf\u3092\u4e00\u62ec\u3057\u3066\u66f4\u65b0\u3059\u308b\u65b9\u6cd5\u306f\u306a\u3044\u3082\u306e\u304b\uff1f<br \/>\n\u30fb\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3059\u308b\u307e\u3067\u3082\u306a\u3044\u3088\u3046\u306aattributes\u3092\u7c21\u5358\u306b\u4fdd\u6301\u3057\u3066\u304a\u304f\u3053\u3068\u306f\u3067\u304d\u306a\u3044\uff1f<\/div>\n<p>\u3068\u3044\u3063\u305f\u7591\u554f\u306b\u7b54\u3048\u308b\u8a18\u4e8b\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4f8b\u306b\u3088\u3063\u3066\u3001\u52d5\u4f5c\u3092\u7406\u89e3\u3059\u308b\u305f\u3081\u306eWeb\u30a2\u30d7\u30ea\u3092\u4f5c\u308b\u3053\u3068\u304b\u3089\u59cb\u3081\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u5b9f\u969b\u306b\u64cd\u4f5c\u3092\u3057\u306a\u304c\u3089\u3001\u52d5\u4f5c\u3092\u7406\u89e3\u3057\u3066\u3044\u3063\u3066\u304f\u3060\u3055\u3044\uff01<\/p>\n<p>\u305d\u308c\u3067\u306f\u3001\u59cb\u3081\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>Active Record\u304a\u3088\u3073O\/R\u30de\u30c3\u30d1\u30fc\u3068\u306f<\/h2>\n<p><span style=\"color: #54a870;\"><strong>Active Record<\/strong><\/span>\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3055\u308c\u308b\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u6271\u3046\u305f\u3081\u306e\u30b3\u30f3\u30dd\u30fc\u30cd\u30f3\u30c8\u3067\u3059\u3002<\/p>\n<p>Rails\u3067\u306f\u3001Active Record\u3092\u901a\u3057\u3066\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3057\u305f\u308a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30c7\u30fc\u30bf\u3092\u4fdd\u5b58\u3057\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #54a870;\"><strong>O\/R\u30de\u30c3\u30d1\u30fc<\/strong><\/span>\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u3068\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u6a4b\u6e21\u3057\u3059\u308b\u5f79\u76ee\u3092\u62c5\u3046\u30e2\u30ce\u3067\u3059\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u30c7\u30fc\u30bf\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u5229\u7528\u3059\u308b\u306b\u306f\u3001SQL\u6587\u3092\u5229\u7528\u3057\u3066\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3057\u3001\u305d\u306e\u30c7\u30fc\u30bf\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u6271\u3046\u5909\u6570\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u51e6\u7406\u3092\u30b9\u30e0\u30fc\u30ba\u306b\u884c\u3046\u30e2\u30ce\u304cO\/R\u30de\u30c3\u30d1\u30fc\u3067\u3059\u3002<\/p>\n<p>Rails\u3067\u306fActive Record\u306bO\/R\u30de\u30c3\u30d1\u30fc\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u305f\u3081\u3001<span style=\"color: #254df2;\"><strong>Active Record\u3092\u4f7f\u3048\u3070\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u304b\u3089\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3057\u305f\u308a\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30c7\u30fc\u30bf\u3092\u4fdd\u5b58\u3057\u305f\u308a\u3068\u3044\u3063\u305f\u51e6\u7406\u304c\u30b9\u30e0\u30fc\u30ba\u306b\u884c\u3048\u308b<\/strong><\/span>\u3001\u3068\u8003\u3048\u308c\u3070\u3088\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<h2>attributes\u3068\u306f<\/h2>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u53d6\u308a\u6271\u3046<span style=\"color: #54a870;\"><strong>attributes<\/strong><\/span>\u306f\u3001\u30e2\u30c7\u30eb\u306b\u542b\u307e\u308c\u308b<span style=\"color: #254df2;\"><strong>\u3059\u3079\u3066\u306e\u5c5e\u6027<\/strong><\/span>\u3092\u6307\u3057\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067User\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3057\u305f\u3068\u304d\u306b\u3001<\/p>\n<pre class=\"decode:true \" >bin\/rails generate scaffold User name:string<\/pre>\n<p>\u300c@user.name\u300d\u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u300cname\u300d\u306e\u3053\u3068\u3092\u3001attributes\u3068\u547c\u3093\u3067\u3044\u307e\u3059\u3002<\/p>\n<h2>\u52d5\u4f5c\u3092\u7406\u89e3\u3059\u308b\u305f\u3081\u306eWeb\u30a2\u30d7\u30ea\u3092\u4f5c\u6210\u3059\u308b<\/h2>\n<p>attributes\u306e\u53d6\u308a\u6271\u3044\u3092\u7406\u89e3\u3059\u308b\u305f\u3081\u306b\u3001Rails\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066Web\u30a2\u30d7\u30ea\u3092\u4f5c\u308a\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\uff081\uff09<span style=\"color: #339966;\"><strong>Rails<\/strong><\/span>\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<p>\u79c1\u306f\u3001\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3092\u53c2\u8003\u306b\u3001VirtualBox\u3067\u4f5c\u6210\u3057\u305f\u4eee\u60f3\u30d1\u30bd\u30b3\u30f3\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305fLinux Mint\u306b\u3001Rails\u306e\u958b\u767a\u74b0\u5883\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u57fa\u672c\u7684\u306b\u306f\u8a18\u4e8b\u306e\u624b\u9806\u306b\u5f93\u3063\u3066\u64cd\u4f5c\u3057\u307e\u3059\u304c\u3001app\/samurai\/sample1\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3059\u308b\u4ee3\u308f\u308a\u306b\u3001<span style=\"color: #54a870;\"><strong>app\/samurai\/attributes-demo\u30c7\u30a3\u30ec\u30af\u30c8\u30ea<\/strong><\/span>\u3092\u4f5c\u6210\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>Rails\u3092\u8d77\u52d5\u3057\u3066\u3001\u30d6\u30e9\u30a6\u30b6\u3067\u753b\u9762\u304c\u8868\u793a\u3055\u308c\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u305f\u3089\u3001\u3044\u3063\u305f\u3093Rails\u3092\u7d42\u4e86\u3057\u3066\u304b\u3089\u6b21\u306b\u9032\u307f\u307e\u3059\u3002<\/p>\n            <a href=\"https:\/\/www.sejuku.net\/blog\/39936\" class=\"blog-card-anchor\">\n                <div class=\"blog-card\">\n                <div class=\"blog-card-content\">\n                    <div class=\"blog-card-thumbnail\">\n                    <img decoding=\"async\" class=\"blog-card-thumbnail-img\" src=\"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/12\/ruby_on_rails-150x86.jpg\">\n                    <\/div>\n                    <div class=\"blog-card-title-wrap\">\n                    <div class=\"blog-card-title\">\u521d\u5fc3\u8005\u3067\u3082\u304b\u3093\u305f\u3093\uff01Ruby on Rails \u306e\u958b\u767a\u74b0\u5883\u306e\u69cb\u7bc9\u624b\u9806\uff08Mac\/Windows \u4e21\u5bfe\u5fdc\uff09<\/div>\n                    <div class=\"blog-card-update-date\">\u66f4\u65b0\u65e5\uff1a2024\u5e745\u67086\u65e5<\/div>\n                    <\/div>\n                <\/div>\n                <\/div>\n            <\/a>\n            \n<p>Linux Mint\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306b\u3064\u3044\u3066\u306f\u3001\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3067\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n            <a href=\"https:\/\/www.sejuku.net\/blog\/56765\" class=\"blog-card-anchor\">\n                <div class=\"blog-card\">\n                <div class=\"blog-card-content\">\n                    <div class=\"blog-card-thumbnail\">\n                    <img decoding=\"async\" class=\"blog-card-thumbnail-img\" src=\"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2018\/06\/linux-mint-150x86.jpg\">\n                    <\/div>\n                    <div class=\"blog-card-title-wrap\">\n                    <div class=\"blog-card-title\">Linux Mint Cinnamon\u30a8\u30c7\u30a3\u30b7\u30e7\u30f3\u3092\u4f7f\u3063\u3066\u307f\u3088\u3046<\/div>\n                    <div class=\"blog-card-update-date\">\u66f4\u65b0\u65e5\uff1a2024\u5e745\u67086\u65e5<\/div>\n                    <\/div>\n                <\/div>\n                <\/div>\n            <\/a>\n            \n<p>\uff082\uff09<span style=\"color: #339966;\"><strong>Gemfile<\/strong><\/span>\u306e\u6700\u7d42\u884c\u306b\u4ee5\u4e0b\u306e\u5185\u5bb9\u3092\u8ffd\u8a18\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >gem 'hirb'\r\ngem 'hirb-unicode'<\/pre>\n<p>Hirb\u306b\u3064\u3044\u3066\u306f\u3001\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3067\u8a73\u3057\u304f\u8aac\u660e\u3057\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u3042\u308f\u305b\u3066\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n            <a href=\"https:\/\/www.sejuku.net\/blog\/27497\" class=\"blog-card-anchor\">\n                <div class=\"blog-card\">\n                <div class=\"blog-card-content\">\n                    <div class=\"blog-card-thumbnail\">\n                    <img decoding=\"async\" class=\"blog-card-thumbnail-img\" src=\"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/07\/image-18-150x86.jpg\">\n                    <\/div>\n                    <div class=\"blog-card-title-wrap\">\n                    <div class=\"blog-card-title\">\u3010Rails\u5165\u9580\u3011\u521d\u5fc3\u8005\u304c\u77e5\u3063\u3066\u304a\u304f\u3079\u304d3\u3064\u306egem<\/div>\n                    <div class=\"blog-card-update-date\">\u66f4\u65b0\u65e5\uff1a2024\u5e745\u67086\u65e5<\/div>\n                    <\/div>\n                <\/div>\n                <\/div>\n            <\/a>\n            \n<p>\uff083\uff09\u65b0\u3057\u3044<span style=\"color: #339966;\"><strong>\u300c\u7aef\u672b\u300d<\/strong><\/span>\u3092\u8d77\u52d5\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u30921\u884c\u305a\u3064\u9806\u756a\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >cd app\/samurai\/attributes-demo\r\nbundle install\r\nbin\/rails generate scaffold User name:string\r\nbin\/rails generate scaffold Post user_id:integer title:string month:integer\r\nbin\/rails db:migrate\r\nbin\/rails console<\/pre>\n<p>\uff084\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u30921\u884c\u305a\u3064\u9806\u756a\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >User.create(name:\"\u5c71\u7530\u592a\u90ce\")\r\nUser.create(name:\"\u9577\u702c\u6765\")\r\nUser.create(name:\"\u7acb\u5ddd\u88d5\u7f8e\")\r\nUser.create(name:\"\u524d\u7530\u9054\u90ce\")\r\nUser.create(name:\"\u7d30\u5ddd\u4fee\u4e8c\")\r\nUser.create(name:\"\u6728\u6751\u62d3\u78e8\")\r\nPost.create(user_id:5, title:\"\u697d\u3057\u3044\u4f11\u65e5\u306e\u904e\u3054\u3057\u65b9\", month:3)\r\nPost.create(user_id:1, title:\"\u5148\u65e5\u306e\u65c5\u884c\u3067\u306e\u8a71\", month:2)\r\nPost.create(user_id:3, title:\"\u6628\u65e5\u306e\u51fa\u6765\u4e8b\", month:12)\r\nPost.create(user_id:3, title:\"\u5c71\u767b\u308a\u306b\u884c\u304d\u307e\u3057\u305f\", month:8)\r\nPost.create(user_id:4, title:\"\u53cb\u4eba\u304c\u7d50\u5a5a\u3057\u307e\u3057\u305f\", month:4)\r\nPost.create(user_id:2, title:\"\u6700\u8fd1\u5c11\u3057\u6c17\u306b\u306a\u3063\u305f\u3053\u3068\", month:1)\r\nPost.create(user_id:4, title:\"\u30e9\u30f3\u30cb\u30f3\u30b0\u306e\u30b3\u30c4\", month:9)\r\nPost.create(user_id:3, title:\"Ruby on Rails\u306e\u65e5\", month:9)\r\nexit<\/pre>\n<p>User\u30c6\u30fc\u30d6\u30eb\u3068Post\u30c6\u30fc\u30d6\u30eb\u306b\u30c7\u30fc\u30bf\u304c\u5165\u529b\u3055\u308c\u3001Rails\u30b3\u30f3\u30bd\u30fc\u30eb\u304c\u7d42\u4e86\u3057\u307e\u3059\u3002<\/p>\n<p>\u6b21\u306bUser\u30c6\u30fc\u30d6\u30eb\u3068Post\u30c6\u30fc\u30d6\u30eb\u3092\u95a2\u9023\u4ed8\u3051\u307e\u3059\u3002<\/p>\n<p>\uff085\uff09<span style=\"color: #339966;\"><strong>app\/models\/user.rb<\/strong><\/span>\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u7de8\u96c6\u3057\u307e\u3059\u3002<\/p>\n<p>\u5909\u66f4\u524d\uff1a<\/p>\n<pre class=\"decode:true \" >class User < ApplicationRecord\r\nend<\/pre>\n<p>\u5909\u66f4\u5f8c\uff1a<\/p>\n<pre class=\"decode:true \" >class User < ApplicationRecord\r\n  has_many :posts\r\n  accepts_nested_attributes_for :posts\r\nend<\/pre>\n<p>\uff086\uff09<span style=\"color: #339966;\"><strong>app\/models\/post.rb<\/strong><\/span>\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u7de8\u96c6\u3057\u307e\u3059\u3002<\/p>\n<p>\u5909\u66f4\u524d\uff1a<\/p>\n<pre class=\"decode:true \" >class Post < ApplicationRecord\r\nend<\/pre>\n<p>\u5909\u66f4\u5f8c\uff1a<\/p>\n<pre class=\"decode:true \" >class Post < ApplicationRecord\r\n  belongs_to :user\r\nend<\/pre>\n<p>\u3053\u308c\u3067\u3001\u6e96\u5099\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<h2>\u30c7\u30fc\u30bf\u306eattributes\u3092\u66f4\u65b0\u3059\u308b<\/h2>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306e\u30c7\u30fc\u30bf\u306eattributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u3001\u4fdd\u5b58\u3059\u308b\u30bf\u30a4\u30df\u30f3\u30b0\u304c\u7570\u306a\u308b2\u3064\u306e\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<h3>\u30c7\u30fc\u30bf\u306eattributes\u3092\u4e00\u62ec\u3067\u66f4\u65b0\u3057\u3066\u3042\u3068\u3067\u4fdd\u5b58\u3059\u308b\u5834\u5408<\/h3>\n<p>\u30c7\u30fc\u30bf\u306eattributes\u3092\u4e00\u62ec\u3067\u66f4\u65b0\u3057\u3066\u3001<span style=\"color: #254df2;\"><strong>\u3042\u3068\u3067\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3059\u308b\u65b9\u6cd5<\/strong><\/span>\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<p>\u5177\u4f53\u7684\u306b\u306f\u3001<span style=\"color: #54a870;\"><strong>attributes<\/strong><\/span>\u307e\u305f\u306f<span style=\"color: #54a870;\"><strong>assign_attributes<\/strong><\/span>\u3092\u4f7f\u3063\u3066attributes\u3092\u4e00\u62ec\u3067\u66f4\u65b0\u3057\u3001<span style=\"color: #54a870;\"><strong>save<\/strong><\/span>\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n<p>\uff081\uff09<span style=\"color: #339966;\"><strong>\u300c\u7aef\u672b\u300d<\/strong><\/span>\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >bin\/rails console<\/pre>\n<p>\uff082\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u30921\u884c\u305a\u3064\u9806\u756a\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >Hirb.enable\r\n@post = Post.find(1)\r\n@post.attributes = { title: '\u65e5\u66dc\u65e5\u3068\u795d\u65e5\u306e\u671d\u3054\u306f\u3093', month: 5 }\r\n@post<\/pre>\n<p>1\u756a\u76ee\u306ePost\u30c7\u30fc\u30bf\u306eattributes\uff08title\u3068month\uff09\u304c\u4e00\u62ec\u3067\u66f4\u65b0\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \" >+----+---------+------------------------+-------+-------------------------+-------------------------+\r\n| id | user_id | title                  | month | created_at              | updated_at              |\r\n+----+---------+------------------------+-------+-------------------------+-------------------------+\r\n| 1  | 5       | \u65e5\u66dc\u65e5\u3068\u795d\u65e5\u306e\u671d\u3054\u306f\u3093 | 5     | 2018-07-17 14:20:46 UTC | 2018-07-17 14:20:46 UTC |\r\n+----+---------+------------------------+-------+-------------------------+-------------------------+\r\n1 row in set<\/pre>\n<p>\u306a\u304a\u30013\u884c\u76ee\u306e\u30b3\u30fc\u30c9\u306f\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3067\u3082\u540c\u3058\u52d5\u4f5c\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >@post.assign_attributes({ title: '\u65e5\u66dc\u65e5\u3068\u795d\u65e5\u306e\u671d\u3054\u306f\u3093', month: 5 })<\/pre>\n<p>\u305f\u3060\u3057\u3001\u3053\u306e\u6642\u70b9\u3067\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u306f\u4fdd\u5b58\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002<\/p>\n<p>\u3044\u3063\u305f\u3093Rails\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u518d\u8d77\u52d5\u3057\u3066\u30011\u756a\u76ee\u306ePost\u30c7\u30fc\u30bf\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\uff083\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >exit<\/pre>\n<p>Rails\u30b3\u30f3\u30bd\u30fc\u30eb\u304c\u7d42\u4e86\u3057\u307e\u3059\u3002<\/p>\n<p>\uff084\uff09\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >bin\/rails console<\/pre>\n<p>\uff085\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >Hirb.enable\r\n@post = Post.find(1)<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \" >  Post Load (0.3ms)  SELECT  \"posts\".* FROM \"posts\" WHERE \"posts\".\"id\" = ? LIMIT ?  [[\"id\", 1], [\"LIMIT\", 1]]\r\n+----+---------+----------------------+-------+-------------------------+-------------------------+\r\n| id | user_id | title                | month | created_at              | updated_at              |\r\n+----+---------+----------------------+-------+-------------------------+-------------------------+\r\n| 1  | 5       | \u697d\u3057\u3044\u4f11\u65e5\u306e\u904e\u3054\u3057\u65b9 | 3     | 2018-07-17 14:20:46 UTC | 2018-07-17 14:20:46 UTC |\r\n+----+---------+----------------------+-------+-------------------------+-------------------------+\r\n1 row in set<\/pre>\n<p>\u6b8b\u5ff5\u306a\u304c\u3089\u5143\u306e\u5185\u5bb9\u306b\u623b\u3063\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u5148\u307b\u3069\u306eattributes\u3067\u5909\u66f4\u3057\u305f\u5185\u5bb9\u304c<span style=\"color: #f75959;\"><strong>\u4fdd\u5b58\u3055\u308c\u3066\u3044\u306a\u3044<\/strong><\/span>\u3053\u3068\u304c\u308f\u304b\u308a\u307e\u3059\u3002<\/p>\n<p>\uff086\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u30921\u884c\u305a\u3064\u9806\u756a\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >@post.attributes = { title: '\u65e5\u66dc\u65e5\u3068\u795d\u65e5\u306e\u671d\u3054\u306f\u3093', month: 5 }\r\n@post.save()\r\nexit<\/pre>\n<p>@post.save()\u3092\u5b9f\u884c\u3057\u305f\u305f\u3081\u3001\u4eca\u5ea6\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u540c\u3058\u3088\u3046\u306b\u3044\u3063\u305f\u3093Rails\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u518d\u8d77\u52d5\u3057\u3066\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\uff087\uff09\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >bin\/rails console<\/pre>\n<p>\uff088\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u30921\u884c\u305a\u3064\u9806\u756a\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >Hirb.enable\r\n@post = Post.find(1)<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \" >  Post Load (0.2ms)  SELECT  \"posts\".* FROM \"posts\" WHERE \"posts\".\"id\" = ? LIMIT ?  [[\"id\", 1], [\"LIMIT\", 1]]\r\n+----+---------+------------------------+-------+-------------------------+-------------------------+\r\n| id | user_id | title                  | month | created_at              | updated_at              |\r\n+----+---------+------------------------+-------+-------------------------+-------------------------+\r\n| 1  | 5       | \u65e5\u66dc\u65e5\u3068\u795d\u65e5\u306e\u671d\u3054\u306f\u3093 | 5     | 2018-07-17 14:20:46 UTC | 2018-07-17 14:28:07 UTC |\r\n+----+---------+------------------------+-------+-------------------------+-------------------------+\r\n1 row in set<\/pre>\n<p><span style=\"color: #254df2;\"><strong>\u4eca\u5ea6\u306f\u3057\u3063\u304b\u308a\u3068\u4fdd\u5b58\u3055\u308c\u3066\u3044\u307e\u3059\u306d\uff01<\/strong><\/span><\/p>\n<h3>\u30c7\u30fc\u30bf\u306eattribute\u3092\u4e00\u62ec\u3067\u66f4\u65b0\u3057\u3066\u3059\u3050\u306b\u4fdd\u5b58\u3059\u308b\u5834\u5408<\/h3>\n<p>\u30c7\u30fc\u30bf\u306eattribute\u3092\u4e00\u62ec\u3067\u66f4\u65b0\u3057\u3066\u3001<span style=\"color: #254df2;\"><strong>\u3059\u3050\u306b\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3059\u308b\u65b9\u6cd5<\/strong><\/span>\u3092\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n<p>\u5177\u4f53\u7684\u306b\u306f\u3001<span style=\"color: #54a870;\"><strong>update_attributes<\/strong><\/span>\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u3092\u4e00\u62ec\u3067\u66f4\u65b0\u3057\u307e\u3059\u3002<\/p>\n<p>\uff081\uff09<span style=\"color: #54a870;\"><strong>\u300c\u7aef\u672b\u300d<\/strong><\/span>\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >bin\/rails console<\/pre>\n<p>\uff082\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u30921\u884c\u305a\u3064\u9806\u756a\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >@post = Post.find(1)\r\n@post.update_attributes({ user_id: 2, title: '\u91d1\u66dc\u65e5\u306e\u30c7\u30a3\u30ca\u30fc', month: 2 })\r\nexit<\/pre>\n<p>\u4f8b\u306b\u3088\u3063\u3066\u3001Rails\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u518d\u8d77\u52d5\u3057\u3066\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\uff083\uff09\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >bin\/rails console<\/pre>\n<p>\uff084\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >Hirb.enable\r\n@post = Post.find(1)<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \" >  Post Load (0.1ms)  SELECT  \"posts\".* FROM \"posts\" WHERE \"posts\".\"id\" = ? LIMIT ?  [[\"id\", 1], [\"LIMIT\", 1]]\r\n+----+---------+------------------+-------+-------------------------+-------------------------+\r\n| id | user_id | title            | month | created_at              | updated_at              |\r\n+----+---------+------------------+-------+-------------------------+-------------------------+\r\n| 1  | 2       | \u91d1\u66dc\u65e5\u306e\u30c7\u30a3\u30ca\u30fc | 2     | 2018-07-17 14:20:46 UTC | 2018-07-17 14:33:19 UTC |\r\n+----+---------+------------------+-------+-------------------------+-------------------------+\r\n1 row in set<\/pre>\n<p><span style=\"color: #254df2;\"><strong>\u3057\u3063\u304b\u308a\u3068\u4fdd\u5b58\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/strong><\/span><\/p>\n<p>\uff085\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >exit<\/pre>\n<h3>\u30b9\u30c8\u30ed\u30f3\u30b0\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u5229\u7528\u3059\u308b<\/h3>\n<p><span style=\"color: #54a870;\"><strong>\u30b9\u30c8\u30ed\u30f3\u30b0\u30d1\u30e9\u30e1\u30fc\u30bf\uff08Strong Parameter\uff09<\/strong><\/span>\u306f\u3001\u9001\u3089\u308c\u3066\u304d\u305f\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u5b89\u5168\u306b\u3001\u30c7\u30fc\u30bf\u306eattributes\u306b\u53cd\u6620\u3059\u308b\u305f\u3081\u306e\u4ed5\u7d44\u307f\u3067\u3059\u3002<\/p>\n<p>\u30b9\u30c8\u30ed\u30f3\u30b0\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4f7f\u7528\u305b\u305a\u306b\u767a\u751f\u3059\u308b\u305c\u3044\u5f31\u6027\u3092\u3001<span style=\"color: #54a870;\"><strong>\u30de\u30b9\u30a2\u30b5\u30a4\u30f3\u30e1\u30f3\u30c8\uff08Mass Assignment\uff09\u305c\u3044\u5f31\u6027<\/strong><\/span>\u3068\u547c\u3073\u307e\u3059\u3002<\/p>\n<p>\u30b9\u30c8\u30ed\u30f3\u30b0\u30d1\u30e9\u30e1\u30fc\u30bf\u3084\u30de\u30b9\u30a2\u30b5\u30a4\u30f3\u30e1\u30f3\u30c8\u305c\u3044\u5f31\u6027\u306b\u3064\u3044\u3066\u306f\u3001\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3067\u3082\u89e6\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u3042\u308f\u305b\u3066\u3054\u89a7\u304f\u3060\u3055\u3044\u3002<\/p>\n            <a href=\"https:\/\/www.sejuku.net\/blog\/29763\" class=\"blog-card-anchor\">\n                <div class=\"blog-card\">\n                <div class=\"blog-card-content\">\n                    <div class=\"blog-card-thumbnail\">\n                    <img decoding=\"async\" class=\"blog-card-thumbnail-img\" src=\"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/08\/image-43-150x86.jpg\">\n                    <\/div>\n                    <div class=\"blog-card-title-wrap\">\n                    <div class=\"blog-card-title\">\u3010Rails\u5165\u9580\u3011params\u4f7f\u3044\u65b9\u307e\u3068\u3081<\/div>\n                    <div class=\"blog-card-update-date\">\u66f4\u65b0\u65e5\uff1a2024\u5e745\u67086\u65e5<\/div>\n                    <\/div>\n                <\/div>\n                <\/div>\n            <\/a>\n            \n<h2>\u5165\u308c\u5b50\u306e\u30c7\u30fc\u30bf\u306eattributes\u3092\u307e\u3068\u3081\u3066\u66f4\u65b0\u3059\u308b<\/h2>\n<p>\u3053\u3053\u304b\u3089\u306f\u3001\u5165\u308c\u5b50\u306e\u30c7\u30fc\u30bf\u306eattributes\u3092\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u307e\u3068\u3081\u3066\u66f4\u65b0\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >@user.attributes = {\r\n    name:\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u3055\u3093\",\r\n    posts_attributes:[\r\n        {id:3, title: \"\u304d\u306e\u3046\u306e\u3067\u304d\u3054\u3068\"},\r\n        {id:4, title:\"\u3042\u3057\u305f\u306e\u3088\u3066\u3044\", month: 5},\r\n        {id:8, title:\"Rails\u306e\u3072\", month: 10}\r\n    ]\r\n}<\/pre>\n<p>\uff081\uff09\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >bin\/rails console<\/pre>\n<p>\uff082\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u30921\u884c\u305a\u3064\u9806\u756a\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >Hirb.enable\r\n@user = User.find(3)\r\n@user.posts<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \" >  Post Load (0.3ms)  SELECT \"posts\".* FROM \"posts\" WHERE \"posts\".\"user_id\" = ?  [[\"user_id\", 3]]\r\n+----+---------+--------------------+-------+-------------------------+-------------------------+\r\n| id | user_id | title              | month | created_at              | updated_at              |\r\n+----+---------+--------------------+-------+-------------------------+-------------------------+\r\n| 3  | 3       | \u6628\u65e5\u306e\u51fa\u6765\u4e8b       | 12    | 2018-07-17 14:20:46 UTC | 2018-07-17 14:20:46 UTC |\r\n| 4  | 3       | \u5c71\u767b\u308a\u306b\u884c\u304d\u307e\u3057\u305f | 8     | 2018-07-17 14:20:46 UTC | 2018-07-17 14:20:46 UTC |\r\n| 8  | 3       | Ruby on Rails\u306e\u65e5  | 9     | 2018-07-17 14:20:46 UTC | 2018-07-17 14:20:46 UTC |\r\n+----+---------+--------------------+-------+-------------------------+-------------------------+\r\n3 rows in set<\/pre>\n<p>3\u3064\u306ePost\u30c7\u30fc\u30bf\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e3\u3064\u306ePost\u30c7\u30fc\u30bf\u306eattributes\u3092\u307e\u3068\u3081\u3066\u66f4\u65b0\u3057\u307e\u3059\u3002<\/p>\n<p>\uff083\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u30921\u884c\u305a\u3064\u9806\u756a\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >@user.attributes = {\r\n    name:\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u3055\u3093\",\r\n    posts_attributes:[\r\n        {id:3, title: \"\u660e\u65e5\u306e\u4e88\u5b9a\"},\r\n        {id:4, title: \"\u6d77\u6c34\u6d74\u306b\u884c\u304d\u307e\u3057\u3087\u3046\"},\r\n        {id:8, title: \"Ruby on Rails\u52c9\u5f37\u4f1a\", month: 10}\r\n    ]\r\n}\r\n@user.posts<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \" >+----+---------+----------------------+-------+-------------------------+-------------------------+\r\n| id | user_id | title                | month | created_at              | updated_at              |\r\n+----+---------+----------------------+-------+-------------------------+-------------------------+\r\n| 3  | 3       | \u660e\u65e5\u306e\u4e88\u5b9a           | 12    | 2018-07-17 14:20:46 UTC | 2018-07-17 14:20:46 UTC |\r\n| 4  | 3       | \u6d77\u6c34\u6d74\u306b\u884c\u304d\u307e\u3057\u3087\u3046 | 8     | 2018-07-17 14:20:46 UTC | 2018-07-17 14:20:46 UTC |\r\n| 8  | 3       | Ruby on Rails\u52c9\u5f37\u4f1a  | 10    | 2018-07-17 14:20:46 UTC | 2018-07-17 14:20:46 UTC |\r\n+----+---------+----------------------+-------+-------------------------+-------------------------+\r\n3 rows in set<\/pre>\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u304c\u4e88\u60f3\u3069\u304a\u308a\u306b\u52d5\u4f5c\u3059\u308b\u306e\u306f\u3001<span style=\"color: #339966;\"><strong>app\/models\/user.rb<\/strong><\/span>\u306b\u3001<span style=\"color: #54a870;\"><strong>accepts_nested_attributes_for :posts<\/strong><\/span>\u3092\u66f8\u3044\u305f\u305f\u3081\u3067\u3059\u3002<\/p>\n<p>\u3067\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3057\u3066\u304b\u3089\u3001Rails\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u7d42\u4e86\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\uff084\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u30921\u884c\u305a\u3064\u9806\u756a\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >@user.save\r\nexit<\/pre>\n<h2>Virtual Attributes\u3092\u5229\u7528\u3059\u308b<\/h2>\n<p><span style=\"color: #54a870;\"><strong>Virtual Attributes<\/strong><\/span>\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u5b58\u5728\u305b\u305a<span style=\"color: #254df2;\"><strong>Model\u306b\u3060\u3051\u5b58\u5728\u3059\u308battributes<\/strong><\/span>\u306e\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u5b58\u5728\u3057\u3066\u3044\u305f\u65b9\u304c\u4fbf\u5229\u306aattributes\u3092\u8a18\u9332\u3057\u3066\u304a\u304f\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u3067\u306f\u3001\u7c21\u5358\u306aVirtual Attributes\u3068\u3057\u3066\u3001User\u30c6\u30fc\u30d6\u30eb\u306ename\u306e\u6587\u5b57\u6570\u3092\u3001name_length\u306b\u4e00\u6642\u7684\u306b\u8a18\u9332\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\uff081\uff09<span style=\"color: #339966;\"><strong>app\/models\/user.rb<\/strong><\/span>\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u7de8\u96c6\u3057\u307e\u3059\u3002<\/p>\n<p>\u5909\u66f4\u524d\uff1a<\/p>\n<pre class=\"decode:true \" >class User < ApplicationRecord\r\n  has_many :posts\r\n  accepts_nested_attributes_for :posts\r\nend<\/pre>\n<p>\u5909\u66f4\u5f8c\uff1a<\/p>\n<pre class=\"decode:true \" >class User < ApplicationRecord\r\n  has_many :posts\r\n  accepts_nested_attributes_for :posts\r\n  attr_accessor :name_length\r\nend<\/pre>\n<p>\uff082\uff09<span style=\"color: #339966;\"><strong>\u300c\u7aef\u672b\u300d<\/strong><\/span>\u3067\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u30921\u884c\u305a\u3064\u9806\u756a\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >bin\/rails console<\/pre>\n<p>\uff083\uff09\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u30921\u884c\u305a\u3064\u9806\u756a\u306b\u5165\u529b\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"decode:true \" >@user = User.find(1)\r\n@user.name_length = @user.name.length<\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\uff1a<\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \" >=> 4<\/pre>\n<p>@user.name_length\u306b\u5024\u3092\u767b\u9332\u3067\u304d\u308b\u306e\u306f\u3001<span style=\"color: #54a870;\"><strong>app\/models\/user.rb<\/strong><\/span>\u306b\u3001<span style=\"color: #54a870;\"><strong>attr_accessor :name_length<\/strong><\/span>\u3092\u8ffd\u52a0\u3057\u305f\u305f\u3081\u3067\u3059\u3002<\/p>\n<p>\u305f\u3068\u3048\u3070\u3001@user.dummy = 4\u3068\u3044\u3063\u305f\u3088\u3046\u306b\u9069\u5f53\u306aattributes\u3092\u3067\u3063\u3061\u4e0a\u3052\u3066\u30c7\u30fc\u30bf\u3092\u767b\u9332\u3057\u3088\u3046\u3068\u3057\u3066\u3082\u3001<span style=\"color: #f75959;\"><strong>\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/strong><\/span><\/p>\n<p>\u306a\u304a\u3001name_length\u306b\u3064\u3044\u3066\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3001Rails\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u518d\u8d77\u52d5\u3059\u308b\u3068\u3001nil\u306b\u623b\u308a\u307e\u3059\u306e\u3067\u3001\u6ce8\u610f\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #54a870;\"><strong>attr_accessor<\/strong><\/span>\u306b\u3064\u3044\u3066\u306f\u3001\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3067\u3082\u89e6\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u8208\u5473\u306e\u3042\u308b\u65b9\u306f\u3054\u89a7\u3044\u305f\u3060\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n            <a href=\"https:\/\/www.sejuku.net\/blog\/14168\" class=\"blog-card-anchor\">\n                <div class=\"blog-card\">\n                <div class=\"blog-card-content\">\n                    <div class=\"blog-card-thumbnail\">\n                    <img decoding=\"async\" class=\"blog-card-thumbnail-img\" src=\"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/12\/ruby_attr2-150x86.jpg\">\n                    <\/div>\n                    <div class=\"blog-card-title-wrap\">\n                    <div class=\"blog-card-title\">\u3010Ruby\u5165\u9580\u3011attr_accessor\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081<\/div>\n                    <div class=\"blog-card-update-date\">\u66f4\u65b0\u65e5\uff1a2024\u5e745\u67086\u65e5<\/div>\n                    <\/div>\n                <\/div>\n                <\/div>\n            <\/a>\n            \n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u4eca\u56de\u306f<span style=\"color: #54a870;\"><strong>Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09<\/strong><\/span>\u3068\u30c7\u30fc\u30bf\u306e<span style=\"color: #54a870;\"><strong>attributes<\/strong><\/span>\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u3001<span style=\"color: #254df2;\"><strong>\u30c7\u30fc\u30bf\u306eattributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5\u3092\u3044\u304f\u3064\u304b\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/strong><\/span><\/p>\n<p>\u521d\u3081\u306b\u3001\u30c7\u30fc\u30bf\u30921\u3064\u53d6\u308a\u51fa\u3057\u3066\u3001\u305d\u306e\u30c7\u30fc\u30bf\u306eattributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><span style=\"color: #54a870;\"><strong>attributes<\/strong><\/span>\u307e\u305f\u306f<span style=\"color: #54a870;\"><strong>assign_attributes<\/strong><\/span>\u3092\u4f7f\u3046\u3060\u3051\u3067\u306f\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3055\u308c\u3066\u3044\u306a\u3044\u305f\u3081\u3001<span style=\"color: #254df2;\"><strong>\u6700\u5f8c\u306bsave\u304c\u5fc5\u8981\u3067\u3057\u305f\u3002<\/strong><\/span><\/p>\n<p>\u307e\u305f\u3001<span style=\"color: #54a870;\"><strong>update_attributes<\/strong><\/span>\u3092\u4f7f\u3046\u3068\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u4fdd\u5b58\u3055\u308c\u308b\u305f\u3081\u3001<span style=\"color: #254df2;\"><strong>\u6700\u5f8c\u306esave\u306f\u4e0d\u8981\u3067\u3057\u305f\u3002<\/strong><\/span><\/p>\n<p>\u5c11\u3057\u5fdc\u7528\u7684\u306a\u4f7f\u3044\u304b\u305f\u3068\u3057\u3066\u3001\u5165\u308c\u5b50\u306e\uff08has_many\u306e\u95a2\u4fc2\u306b\u3042\u308b\uff09\u30c7\u30fc\u30bf\u3092\u3001attributes\u3001assign_attributes\u3001\u307e\u305f\u306fupdate_attributes\u3092\u4f7f\u3063\u3066\u4e00\u62ec\u3067\u66f4\u65b0\u3059\u308b\u305f\u3081\u306b\u306f\u3001<span style=\"color: #54a870;\"><strong>accepts_nested_attributes_for<\/strong><\/span>\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308b\u3053\u3068\u3082\u8aac\u660e\u3057\u307e\u3057\u305f\u306d\u3002<\/p>\n<p>\u6700\u5f8c\u306b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u306f\u4fdd\u5b58\u3059\u308b\u5fc5\u8981\u304c\u306a\u3044\u3082\u306e\u306e\u3001\u3042\u308b\u3068\u4fbf\u5229\u306aattributes\uff08<span style=\"color: #54a870;\"><strong>Virtual Attributes<\/strong><\/span>\u3068\u547c\u3070\u308c\u308battributes\uff09\u3092\u5b9a\u7fa9\u3059\u308b\u65b9\u6cd5\u3092\u8aac\u660e\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>attributes\u3092\u66f4\u65b0\u3059\u308b\u3068\u3044\u3063\u3066\u3082\u69d8\u3005\u306a\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3001<span style=\"color: #f75959;\"><strong>\u6700\u3082\u9069\u5207\u306a\u65b9\u6cd5\u3092\u691c\u8a0e\u3057\u3001\u30b3\u30fc\u30c9\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/strong><\/span><\/p>\n<p>\u305d\u308c\u3067\u306f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u65e5\u306f\u3001Ruby on Rails\uff08\u4ee5\u964d\u3001Rails\uff09\u306eActive Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067\u3001attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5\u3092\u3044\u304f\u3064\u304b\u7d39\u4ecb\u3057\u307e\u3059\u3002 \u30fbattribute\u3084assign_attributes\u3067 [&hellip;]<\/p>\n","protected":false},"author":16433,"featured_media":64405,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"swell_btn_cv_data":"","footnotes":""},"categories":[2352],"tags":[],"class_list":["post-64345","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby-study"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0<\/title>\n<meta name=\"description\" content=\"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5 \u300d\u306b\u3064\u3044\u3066\u3001\u8ab0\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001\u3042\u306a\u305f\u306e\u60a9\u307f\u304c\u89e3\u6c7a\u3059\u308b\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u65b0\u305f\u306a\u6c17\u4ed8\u304d\u3082\u767a\u898b\u3067\u304d\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002\u304a\u60a9\u307f\u306e\u65b9\u306f\u305c\u3072\u3054\u4e00\u8aad\u304f\u3060\u3055\u3044\u3002\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sejuku.net\/blog\/64345\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0\" \/>\n<meta property=\"og:description\" content=\"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5 \u300d\u306b\u3064\u3044\u3066\u3001\u8ab0\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001\u3042\u306a\u305f\u306e\u60a9\u307f\u304c\u89e3\u6c7a\u3059\u308b\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u65b0\u305f\u306a\u6c17\u4ed8\u304d\u3082\u767a\u898b\u3067\u304d\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002\u304a\u60a9\u307f\u306e\u65b9\u306f\u305c\u3072\u3054\u4e00\u8aad\u304f\u3060\u3055\u3044\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sejuku.net\/blog\/64345\" \/>\n<meta property=\"og:site_name\" content=\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/sejuku2013\" \/>\n<meta property=\"article:published_time\" content=\"1970-01-01T00:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-05-06T02:49:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2018\/07\/rails-attributes1.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"700\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"\u4f8d\u30c6\u30c3\u30af\u7de8\u96c6\u90e8\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@samuraijuku\" \/>\n<meta name=\"twitter:site\" content=\"@samuraijuku\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/64345#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/64345\"},\"author\":{\"name\":\"\u4f8d\u30c6\u30c3\u30af\u7de8\u96c6\u90e8\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#\\\/schema\\\/person\\\/d20c57b59dba15001519a8a671183095\"},\"headline\":\"\u3010Rails\u5165\u9580\u3011Active Record\uff08O\\\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5\",\"datePublished\":\"1970-01-01T00:00:00+00:00\",\"dateModified\":\"2024-05-06T02:49:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/64345\"},\"wordCount\":236,\"publisher\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/64345#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/rails-attributes1.jpg\",\"articleSection\":[\"Ruby\u5b66\u7fd2\"],\"inLanguage\":\"ja\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/64345\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/64345\",\"name\":\"\u3010Rails\u5165\u9580\u3011Active Record\uff08O\\\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/64345#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/64345#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/rails-attributes1.jpg\",\"datePublished\":\"1970-01-01T00:00:00+00:00\",\"dateModified\":\"2024-05-06T02:49:52+00:00\",\"description\":\"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Rails\u5165\u9580\u3011Active Record\uff08O\\\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5 \u300d\u306b\u3064\u3044\u3066\u3001\u8ab0\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001\u3042\u306a\u305f\u306e\u60a9\u307f\u304c\u89e3\u6c7a\u3059\u308b\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u65b0\u305f\u306a\u6c17\u4ed8\u304d\u3082\u767a\u898b\u3067\u304d\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002\u304a\u60a9\u307f\u306e\u65b9\u306f\u305c\u3072\u3054\u4e00\u8aad\u304f\u3060\u3055\u3044\u3002\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/64345#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/64345\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/64345#primaryimage\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/rails-attributes1.jpg\",\"contentUrl\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2018\\\/07\\\/rails-attributes1.jpg\",\"width\":700,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/64345#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Rails\u5165\u9580\u3011Active Record\uff08O\\\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/\",\"name\":\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0\",\"description\":\"\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5b66\u7fd2\u306e\u3059\u3079\u3066\u304c\u30b3\u30b3\u306b\u3002\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ja\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#organization\",\"name\":\"\u682a\u5f0f\u4f1a\u793eSAMURAI\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/logo.png\",\"contentUrl\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/07\\\/logo.png\",\"width\":600,\"height\":600,\"caption\":\"\u682a\u5f0f\u4f1a\u793eSAMURAI\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/sejuku2013\",\"https:\\\/\\\/x.com\\\/samuraijuku\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCCFOQO5aDK0xXam4cUQXT8g\\\/featured\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#\\\/schema\\\/person\\\/d20c57b59dba15001519a8a671183095\",\"name\":\"\u4f8d\u30c6\u30c3\u30af\u7de8\u96c6\u90e8\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d91ed20aaa7f873a0f4f35586561303460c1e3864746dddb6ebe0fb093c1952d?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d91ed20aaa7f873a0f4f35586561303460c1e3864746dddb6ebe0fb093c1952d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d91ed20aaa7f873a0f4f35586561303460c1e3864746dddb6ebe0fb093c1952d?s=96&d=mm&r=g\",\"caption\":\"\u4f8d\u30c6\u30c3\u30af\u7de8\u96c6\u90e8\"},\"description\":\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u587e\u306f\u300c\u4eba\u751f\u3092\u5909\u3048\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5b66\u7fd2\u300d\u3092\u30b3\u30f3\u30bb\u30f3\u30d7\u30c8\u306b\u3001\u904e\u53bb\u591a\u304f\u306e\u30d5\u30ea\u30fc\u30e9\u30f3\u30b9\u30a8\u30f3\u30b8\u30cb\u30a2\u3092\u8f29\u51fa\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb\u3067\u3059\u3002\u4f8d\u30c6\u30c3\u30af\u7de8\u96c6\u90e8\u3067\u306f\u6280\u8853\u7cfb\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u4e2d\u5fc3\u306b\u6709\u7528\u306a\u60c5\u5831\u3092\u767a\u4fe1\u3057\u3066\u3044\u304d\u307e\u3059\u3002\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/author\\\/samurai-tech\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","description":"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5 \u300d\u306b\u3064\u3044\u3066\u3001\u8ab0\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001\u3042\u306a\u305f\u306e\u60a9\u307f\u304c\u89e3\u6c7a\u3059\u308b\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u65b0\u305f\u306a\u6c17\u4ed8\u304d\u3082\u767a\u898b\u3067\u304d\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002\u304a\u60a9\u307f\u306e\u65b9\u306f\u305c\u3072\u3054\u4e00\u8aad\u304f\u3060\u3055\u3044\u3002","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sejuku.net\/blog\/64345","og_locale":"ja_JP","og_type":"article","og_title":"\u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","og_description":"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5 \u300d\u306b\u3064\u3044\u3066\u3001\u8ab0\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001\u3042\u306a\u305f\u306e\u60a9\u307f\u304c\u89e3\u6c7a\u3059\u308b\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u65b0\u305f\u306a\u6c17\u4ed8\u304d\u3082\u767a\u898b\u3067\u304d\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002\u304a\u60a9\u307f\u306e\u65b9\u306f\u305c\u3072\u3054\u4e00\u8aad\u304f\u3060\u3055\u3044\u3002","og_url":"https:\/\/www.sejuku.net\/blog\/64345","og_site_name":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","article_publisher":"https:\/\/www.facebook.com\/sejuku2013","article_published_time":"1970-01-01T00:00:00+00:00","article_modified_time":"2024-05-06T02:49:52+00:00","og_image":[{"width":700,"height":400,"url":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2018\/07\/rails-attributes1.jpg","type":"image\/jpeg"}],"author":"\u4f8d\u30c6\u30c3\u30af\u7de8\u96c6\u90e8","twitter_card":"summary_large_image","twitter_creator":"@samuraijuku","twitter_site":"@samuraijuku","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sejuku.net\/blog\/64345#article","isPartOf":{"@id":"https:\/\/www.sejuku.net\/blog\/64345"},"author":{"name":"\u4f8d\u30c6\u30c3\u30af\u7de8\u96c6\u90e8","@id":"https:\/\/www.sejuku.net\/blog\/#\/schema\/person\/d20c57b59dba15001519a8a671183095"},"headline":"\u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5","datePublished":"1970-01-01T00:00:00+00:00","dateModified":"2024-05-06T02:49:52+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sejuku.net\/blog\/64345"},"wordCount":236,"publisher":{"@id":"https:\/\/www.sejuku.net\/blog\/#organization"},"image":{"@id":"https:\/\/www.sejuku.net\/blog\/64345#primaryimage"},"thumbnailUrl":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2018\/07\/rails-attributes1.jpg","articleSection":["Ruby\u5b66\u7fd2"],"inLanguage":"ja"},{"@type":"WebPage","@id":"https:\/\/www.sejuku.net\/blog\/64345","url":"https:\/\/www.sejuku.net\/blog\/64345","name":"\u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","isPartOf":{"@id":"https:\/\/www.sejuku.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sejuku.net\/blog\/64345#primaryimage"},"image":{"@id":"https:\/\/www.sejuku.net\/blog\/64345#primaryimage"},"thumbnailUrl":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2018\/07\/rails-attributes1.jpg","datePublished":"1970-01-01T00:00:00+00:00","dateModified":"2024-05-06T02:49:52+00:00","description":"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5 \u300d\u306b\u3064\u3044\u3066\u3001\u8ab0\u3067\u3082\u7406\u89e3\u3067\u304d\u308b\u3088\u3046\u306b\u89e3\u8aac\u3057\u307e\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3081\u3070\u3001\u3042\u306a\u305f\u306e\u60a9\u307f\u304c\u89e3\u6c7a\u3059\u308b\u3060\u3051\u3058\u3083\u306a\u304f\u3001\u65b0\u305f\u306a\u6c17\u4ed8\u304d\u3082\u767a\u898b\u3067\u304d\u308b\u3053\u3068\u3067\u3057\u3087\u3046\u3002\u304a\u60a9\u307f\u306e\u65b9\u306f\u305c\u3072\u3054\u4e00\u8aad\u304f\u3060\u3055\u3044\u3002","breadcrumb":{"@id":"https:\/\/www.sejuku.net\/blog\/64345#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sejuku.net\/blog\/64345"]}]},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.sejuku.net\/blog\/64345#primaryimage","url":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2018\/07\/rails-attributes1.jpg","contentUrl":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2018\/07\/rails-attributes1.jpg","width":700,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/www.sejuku.net\/blog\/64345#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sejuku.net\/blog\/"},{"@type":"ListItem","position":2,"name":"\u3010Rails\u5165\u9580\u3011Active Record\uff08O\/R\u30de\u30c3\u30d1\u30fc\uff09\u3067attributes\u3092\u66f4\u65b0\u3059\u308b\u65b9\u6cd5"}]},{"@type":"WebSite","@id":"https:\/\/www.sejuku.net\/blog\/#website","url":"https:\/\/www.sejuku.net\/blog\/","name":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","description":"\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5b66\u7fd2\u306e\u3059\u3079\u3066\u304c\u30b3\u30b3\u306b\u3002","publisher":{"@id":"https:\/\/www.sejuku.net\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sejuku.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ja"},{"@type":"Organization","@id":"https:\/\/www.sejuku.net\/blog\/#organization","name":"\u682a\u5f0f\u4f1a\u793eSAMURAI","url":"https:\/\/www.sejuku.net\/blog\/","logo":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.sejuku.net\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2023\/07\/logo.png","contentUrl":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2023\/07\/logo.png","width":600,"height":600,"caption":"\u682a\u5f0f\u4f1a\u793eSAMURAI"},"image":{"@id":"https:\/\/www.sejuku.net\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/sejuku2013","https:\/\/x.com\/samuraijuku","https:\/\/www.youtube.com\/channel\/UCCFOQO5aDK0xXam4cUQXT8g\/featured"]},{"@type":"Person","@id":"https:\/\/www.sejuku.net\/blog\/#\/schema\/person\/d20c57b59dba15001519a8a671183095","name":"\u4f8d\u30c6\u30c3\u30af\u7de8\u96c6\u90e8","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/secure.gravatar.com\/avatar\/d91ed20aaa7f873a0f4f35586561303460c1e3864746dddb6ebe0fb093c1952d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/d91ed20aaa7f873a0f4f35586561303460c1e3864746dddb6ebe0fb093c1952d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d91ed20aaa7f873a0f4f35586561303460c1e3864746dddb6ebe0fb093c1952d?s=96&d=mm&r=g","caption":"\u4f8d\u30c6\u30c3\u30af\u7de8\u96c6\u90e8"},"description":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u587e\u306f\u300c\u4eba\u751f\u3092\u5909\u3048\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u5b66\u7fd2\u300d\u3092\u30b3\u30f3\u30bb\u30f3\u30d7\u30c8\u306b\u3001\u904e\u53bb\u591a\u304f\u306e\u30d5\u30ea\u30fc\u30e9\u30f3\u30b9\u30a8\u30f3\u30b8\u30cb\u30a2\u3092\u8f29\u51fa\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb\u3067\u3059\u3002\u4f8d\u30c6\u30c3\u30af\u7de8\u96c6\u90e8\u3067\u306f\u6280\u8853\u7cfb\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u4e2d\u5fc3\u306b\u6709\u7528\u306a\u60c5\u5831\u3092\u767a\u4fe1\u3057\u3066\u3044\u304d\u307e\u3059\u3002","url":"https:\/\/www.sejuku.net\/blog\/author\/samurai-tech"}]}},"_links":{"self":[{"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/posts\/64345","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/users\/16433"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/comments?post=64345"}],"version-history":[{"count":0,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/posts\/64345\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/media\/64405"}],"wp:attachment":[{"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/media?parent=64345"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/categories?post=64345"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/tags?post=64345"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}