{"id":26994,"date":"2021-08-01T08:08:09","date_gmt":"1970-01-01T00:00:00","guid":{"rendered":"http:\/\/www.sejuku.net\/blog\/?p=26994"},"modified":"2024-05-06T11:43:52","modified_gmt":"2024-05-06T02:43:52","slug":"%e3%80%90rails%e5%85%a5%e9%96%80%e3%80%91scope%e3%81%ae%e4%bd%bf%e3%81%84%e6%96%b9%e3%81%be%e3%81%a8%e3%82%81","status":"publish","type":"post","link":"https:\/\/www.sejuku.net\/blog\/26994","title":{"rendered":"\u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081"},"content":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f! \u30d5\u30ea\u30fc\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u9577\u702c\u3067\u3059\u3002<\/p>\n<p>\u307f\u306a\u3055\u3093\u306fscope\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u304b\u3002<\/p>\n<p><span style=\"color: #339966\"><strong>scope<\/strong><\/span>\u3092\u4f7f\u3048\u3070\u3001<span style=\"color: #0000ff\"><strong>SQL\u6587\u3092\u30e1\u30bd\u30c3\u30c9\u5316<\/strong><\/span>\u3067\u304d\u308b\u306e\u3067\u30c7\u30fc\u30bf\u7ba1\u7406\u3092\u52b9\u7387\u5316\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001scope\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066<\/p>\n<p><span style=\"color: #ff0000\"><strong>\u30fbscope \u3068\u306f<\/strong><\/span><br \/>\n<span style=\"color: #ff0000\"><strong>\u30fbscope\u306e\u4f7f\u3044\u65b9<\/strong><\/span><\/p>\n<p>\u3068\u3044\u3046\u57fa\u672c\u7684\u306a\u5185\u5bb9\u304b\u3089\u3001<\/p>\n<p><span style=\"color: #ff0000\"><strong>\u30fbscope\u306e\u5fdc\u7528\u7684\u306a\u4f7f\u3044\u65b9<\/strong><\/span><\/p>\n<p>\u3068\u3044\u3063\u305f\u4e00\u6b69\u9032\u3093\u3060\u5185\u5bb9\u306b\u3064\u3044\u3066\u3082\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<h2>scope\u3068\u306f<\/h2>\n<p>\u30e2\u30c7\u30eb\u306b<span style=\"color: #ff0000;background-color: #ffff99\"><strong>scope\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001\u7279\u5b9a\u306eSQL\u6587\u3092\u30e1\u30bd\u30c3\u30c9\u5316<\/strong><\/span>\u3057\u3066\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001\u7e70\u308a\u8fd4\u3057\u3088\u304f\u4f7f\u3046SQL\u6587\u304c\u3042\u308b\u3068\u304d\u306b\u306fscope\u3092\u4f7f\u3063\u3066\u5b9a\u7fa9\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u4eca\u56de\u306fUser\u30e2\u30c7\u30eb\u3068Post\u30e2\u30c7\u30eb\u3092\u4f7f\u3063\u3066\u89e3\u8aac\u3059\u308b\u306e\u3067\u3001\u307e\u305a\u306f\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[User\u30e2\u30c7\u30eb\u3068Post\u30e2\u30c7\u30eb\u3092\u4f5c\u6210\u3057\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u53cd\u6620\u3059\u308b]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">rails g model User name:string age:integer\r\nrails g model Post user:references title:string deleted_at:datetime\r\nrake db:migrate<\/pre>\n<p>\u3053\u308c\u3067\u3001\u4eca\u56de\u4f7f\u3046\u30ab\u30e9\u30e0\u3068\u30e2\u30c7\u30eb\u304c\u4f5c\u6210\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u7d9a\u3044\u3066\u30c7\u30fc\u30bf\u3092\u5165\u308c\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>rails console\u3067\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u8d77\u52d5\u3057\u305f\u5f8c\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[User\u30e2\u30c7\u30eb\u3068Post\u30e2\u30c7\u30eb\u306b\u4eca\u56de\u4f7f\u3046\u30c7\u30fc\u30bf\u3092\u5165\u308c\u308b<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">User.create(name:&quot;\u5c71\u7530\u82b1\u5b50&quot;,age:3)\r\nUser.create(name:&quot;\u9577\u702c\u6765&quot;,age:27)\r\nUser.create(name:&quot;\u5b89\u7530\u4e00\u90ce&quot;,age:11)\r\nUser.create(name:&quot;\u7d30\u7530\u4fca\u4ecb&quot;,age:34)\r\nUser.create(name:&quot;\u5b89\u539f\u5e84\u4e4b\u52a9&quot;,age:88)\r\nUser.create(name:&quot;\u4e2d\u6751\u62d3\u90ce&quot;,age:81)\r\nPost.create(user_id:3,title:&quot;\u697d\u3057\u3044\u4f11\u65e5\u306e\u904e\u3054\u3057\u65b9&quot;,deleted_at:&quot;2017-05-01 09:37:00&quot;.to_datetime,created_at:&quot;2017-04-26 15:29:00&quot;.to_datetime)\r\nPost.create(user_id:2,title:&quot;\u5148\u65e5\u306e\u65c5\u884c\u3067\u306e\u8a71&quot;,created_at:&quot;2017-04-30 23:04:00&quot;.to_datetime ,deleted_at:&quot;2017-05-16 9:38:00&quot;.to_datetime)\r\nPost.create(user_id:1,title:&quot;\u6628\u65e5\u306e\u51fa\u6765\u4e8b&quot; ,created_at: &quot;2017-05-24 13:02:00&quot;.to_datetime)\r\nPost.create(user_id:6,title:&quot;\u5c71\u767b\u308a\u306b\u884c\u304d\u307e\u3057\u305f&quot;,created_at:&quot;2017-05-27 12:37:00&quot;.to_datetime )\r\nPost.create(user_id:4,title:&quot;\u53cb\u4eba\u304c\u7d50\u5a5a\u3057\u307e\u3057\u305f&quot;,created_at: &quot;2017-05-29 14:40:00&quot;.to_datetime)\r\nPost.create(user_id:5,title:&quot;\u53cb\u4eba\u304c\u7d50\u5a5a\u3057\u307e\u3057\u305f&quot;,created_at: &quot;2017-06-8 13:00:00&quot;.to_datetime)\r\nPost.create(user_id:4,title:&quot;\u6700\u8fd1\u5c11\u3057\u6c17\u306b\u306a\u3063\u305f\u3053\u3068&quot;,created_at:&quot;2017-05-16 9:38:00&quot;.to_datetime)\r\nPost.create(user_id:2,title:&quot;\u30e9\u30f3\u30cb\u30f3\u30b0\u306e\u30b3\u30c4&quot;,created_at: &quot;2017-05-2 9:18:00&quot;.to_datetime)<\/pre>\n<p>\u3053\u308c\u3067\u30c7\u30fc\u30bf\u304c\u5165\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u7d9a\u3044\u3066\u3001User\u3068Post\u306e\u95a2\u9023\u4ed8\u3051\u3092\u884c\u3044\u307e\u3059\u306e\u3067\u3001\u305d\u308c\u305e\u308c\u306emodel\u306b\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[app\/models\/user.rb\u306b\u5165\u529b\u3059\u308b\u5185\u5bb9]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">has_many :posts<\/pre>\n<p><span style=\"color: #0000ff\"><strong>[app\/models\/post.rb\u306b\u8a18\u8ff0\u3059\u308b\u5185\u5bb9]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">belongs_to :user<\/pre>\n<p>\u3053\u308c\u3067\u95a2\u9023\u4ed8\u3051\u3092\u8a2d\u5b9a\u3067\u304d\u307e\u3057\u305f\u3002 <\/p>\n<p>\u3067\u306f\u5b9f\u969b\u306b<span style=\"color: #339966\"><strong>scope<\/strong><\/span>\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>app\/models\/user.rb\u306b\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[app\/models\/user.rb\u306b\u5165\u529b\u3059\u308b\u5185\u5bb9]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">scope :young, -&gt; { where(&quot;age &lt; 20&quot;) }<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306byoung\u3068\u3044\u3046scope\u3092\u8a2d\u5b9a\u3057\u305f\u306e\u3067\u3001young\u3068\u3044\u3046<span style=\"color: #0000ff\"><strong>\u30e1\u30bd\u30c3\u30c9\u304c\u4f7f\u3048\u308b<\/strong><\/span>\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3053\u3053\u304b\u3089\u306frails cosole\u306b\u53d6\u308a\u51fa\u3057\u305f\u30c7\u30fc\u30bf\u3092\u51fa\u529b\u3057\u3066\u3044\u304f\u306e\u3067\u3001\u51fa\u529b\u3057\u305f\u30c7\u30fc\u30bf\u306e<span style=\"color: #0000ff\"><strong>\u898b\u6804\u3048\u3092\u826f\u304f\u306b\u3059\u308b<\/strong><\/span>\u305f\u3081\u306b\u4e00\u3064gem\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002(\u3059\u3067\u306b\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u6e08\u307f\u306e\u65b9\u306f\u98db\u3070\u3057\u3066\u3082\u3089\u3063\u3066\u304b\u307e\u3044\u307e\u305b\u3093\u3002)<\/p>\n<p>\u307e\u305a\u3001Gemfile\u306b<br \/>\n<span style=\"color: #0000ff\"><strong>[Gemfile\u306b\u5165\u529b\u3059\u308b\u5185\u5bb9]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">gem 'hirb'         # \u51fa\u529b\u7d50\u679c\u3092\u8868\u3068\u3057\u3066\u51fa\u529b\u3059\u308bgem\r\ngem 'hirb-unicode'  # \u30de\u30eb\u30c1\u30d0\u30a4\u30c8\u6587\u5b57\u306e\u8868\u793a\u3092\u88dc\u6b63\u3059\u308bgem<\/pre>\n<p>\u3092\u8ffd\u8a18\u3057\u3066\u3001\u30b3\u30de\u30f3\u30c9\u30d7\u30ed\u30f3\u30d7\u30c8\u3067<\/p>\n<p><span style=\"color: #0000ff\"><strong>[Gemfile\u306e\u5185\u5bb9\u3092\u53cd\u6620\u3059\u308b]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">bundle install<\/pre>\n<p>\u3092\u5165\u529b\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u3053\u308c\u3067\u3001\u3044\u3064\u3067\u3082Hirb.enable\u3068\u30b3\u30fc\u30bd\u30fc\u30eb\u3067\u5165\u529b\u3059\u308c\u3070Hirb\u306egem\u304c\u6709\u52b9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>rails console\u3067\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u8d77\u52d5\u3057\u305f\u5f8c\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[\u81ea\u5206\u3067\u8a2d\u5b9a\u3057\u305fyoung\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u307f\u308b]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">Hirb.enable #\u8868\u5f62\u5f0f\u3067\u51fa\u529b\r\nUser.young<\/pre>\n<p><span style=\"color: #0000ff\"><strong>[\u5b9f\u884c\u7d50\u679c]<\/strong><\/span><\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \"> User Load (3.9ms)  SELECT &quot;users&quot;.* FROM &quot;users&quot; WHERE (age &lt; 20)\r\n+----+----------+-----+---------------------------+---------------------------+\r\n| id | name     | age | created_at                | updated_at                |\r\n+----+----------+-----+---------------------------+---------------------------+\r\n| 1  | \u5c71\u7530\u82b1\u5b50 | 3   | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n| 3  | \u5b89\u7530\u4e00\u90ce | 11  | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n+----+----------+-----+---------------------------+---------------------------+\r\n2 rows in set<\/pre>\n<p>\u30e2\u30c7\u30eb\u3067\u8a2d\u5b9a\u3057\u305fage\u304c20\u4ee5\u4e0b\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3059young\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306bscope\u3092\u5b9a\u7fa9\u3059\u308c\u3070\u3001<span style=\"color: #0000ff\"><strong>\u3088\u304f\u4f7f\u3046SQL\u6587\u3092\u30e1\u30bd\u30c3\u30c9\u5316<\/strong><\/span>\u3057\u3066\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u304cscope\u3092\u4f7f\u3046\u30e1\u30ea\u30c3\u30c8\u3067\u3059\u3002<\/p>\n<h3>scope\u306e\u57fa\u672c\u69cb\u6587<\/h3>\n<p>\u305d\u308c\u3067\u306f\u3001\u3055\u304d\u307b\u3069\u4f7f\u3063\u305fscope\u306e\u69cb\u6587\u3092\u89e3\u8aac\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[scope\u3067\u5b9a\u7fa9\u3055\u308c\u305fyoung\u30e1\u30bd\u30c3\u30c9\u306e\u4f8b]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">scope :young, -&gt; { where(&quot;age &lt; 20&quot;) }<\/pre>\n<p>scope\u306fmodels\u4ee5\u4e0b\u306e\u30e2\u30c7\u30eb\u540d.rb\u30d5\u30a1\u30a4\u30eb\u5185\u306b\u8a18\u8ff0\u306b\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u3001scope :(\u30e1\u30bd\u30c3\u30c9\u306e\u540d\u524d)\u3067\u30e1\u30bd\u30c3\u30c9\u540d\u3092\u5b9a\u7fa9\u3057\u3066\u305d\u308c\u4ee5\u964d\u306e\u90e8\u5206\u306bSQL\u6587\u3092\u66f8\u3044\u3066\u3044\u304d\u307e\u3059\u3002\u3053\u306e\u69cb\u6587\u306f<span style=\"color: #339966\"><strong>\u30e9\u30e0\u30c0\u5f0f<\/strong><\/span>\u3068\u547c\u3070\u308c\u308b\u3082\u306e\u3067\u3059\u3002<\/p>\n<h3>\u30e9\u30e0\u30c0(lambda)\u5f0f\u3068\u306f<\/h3>\n<p><span style=\"color: #339966\"><strong>\u30e9\u30e0\u30c0\u5f0f<\/strong><\/span>\u3068\u306f\u540d\u524d\u306e\u901a\u308a\u3001\u30e9\u30e0\u30c0\u3092\u4f7f\u3063\u305f\u5f0f\u306e\u3053\u3068\u3067\u3001Rails4\u4ee5\u964d\u306fscope\u306e\u5b9a\u7fa9\u306b\u306f\u30e9\u30e0\u30c0\u5f0f\u3092\u4f7f\u3046\u3053\u3068\u304c<span style=\"color: #0000ff\"><strong>\u5fc5\u9808\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/strong><\/span><\/p>\n<p>\u30e9\u30e0\u30c0\u306b\u3064\u3044\u3066\u8aac\u660e\u3059\u308b\u3068\u30011\u3064\u306e\u8a18\u4e8b\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/p>\n<p>\u3067\u3059\u306e\u3067\u3001\u3053\u3053\u3067\u306f\u30e9\u30e0\u30c0\u5f0f\u306f<span style=\"color: #0000ff\"><strong>\u3044\u304f\u3064\u304b\u306e\u30b3\u30fc\u30c9\u3092\u307e\u3068\u3081\u30661\u3064\u306e\u30e1\u30bd\u30c3\u30c9\u3068\u3057\u3066\u6271\u3046<\/strong><\/span>\u3053\u3068\u3092\u5b9f\u73fe\u3057\u3066\u304f\u308c\u308b\u4fbf\u5229\u306a\u3082\u306e\u3068\u3044\u3046\u8a8d\u8b58\u3067\u5927\u4e08\u592b\u3067\u3059\u3002<\/p>\n<p>Ruby\u306b\u306f\u30e9\u30e0\u30c0(lamda)\u306e\u4ed6\u306bProc\u3068\u3044\u3046\u985e\u4f3c\u306e\u6a5f\u80fd\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n\u6c17\u306b\u306a\u308b\u65b9\u306f\u3053\u3061\u3089\u306e\u8a18\u4e8b\u3092\u53c2\u8003\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n            <a href=\"https:\/\/www.sejuku.net\/blog\/21300\" 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\/09\/ruby_proc03-150x86.jpg\">\n                    <\/div>\n                    <div class=\"blog-card-title-wrap\">\n                    <div class=\"blog-card-title\">\u3010Ruby\u5165\u9580\u3011Proc\u3068Lambda\u306e\u9055\u3044\u307e\u3068\u3081\u3010\u5f15\u6570 return \u30a2\u30ed\u30fc\u3011<\/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             <\/p>\n<p>\u3055\u304d\u307b\u3069\u3001\u4f7f\u3063\u305f\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u4f8b\u306b\u3059\u308b\u3068<\/p>\n<pre class=\"lang:ruby decode:true \">scope :young, -&gt; { where(&quot;age &lt; 20&quot;) }<\/pre>\n<p>scope\u4ee5\u964d\u306e:young, -&gt; \u301c\u304c\u30e9\u30e0\u30c0\u5f0f\u3067\u8a18\u8ff0\u3055\u308c\u3066\u3044\u308b\u90e8\u5206\u3067\u3059\u3002<\/p>\n<h2>scope\u306e\u4f7f\u3044\u65b9<\/h2>\n<h3>scope\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h3>\n<p>\u305d\u308c\u3067\u306fscope\u3092\u5b9f\u8df5\u7684\u306b\u4f7f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u307e\u305a\u306f<span style=\"color: #339966\"><strong>where<\/strong><\/span>\u3092\u4f7f\u3063\u305fscope\u304b\u3089\u3067\u3059\u3002<\/p>\n<p>app\/models\/post.rb\u306b\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[app\/models\/post.rb\u306b\u5165\u529b\u3059\u308b\u5185\u5bb9]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">scope :two_months, -&gt; { where(&quot;created_at &lt; ?&quot;,Time.zone.now-2.month) }<\/pre>\n<p>where\u3092\u4f7f\u3063\u3066\u5b9a\u7fa9\u3057\u305fscope\u3092\u4f7f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<br \/>\nrails console\u3067\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u8d77\u52d5\u3057\u305f\u5f8c\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[two_months\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3059]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">Hirb.enable #\u8868\u5f62\u5f0f\u3067\u51fa\u529b\r\nPost.two_months<\/pre>\n<p><span style=\"color: #0000ff\"><strong>[\u5b9f\u884c\u7d50\u679c]<\/strong><\/span><\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \">Post Load (0.2ms)  SELECT &quot;posts&quot;.* FROM &quot;posts&quot; WHERE (created_at &lt; '2017-05-10 10:10:25.297859')\r\n+----+---------+----------------------+---------------------------+---------------------------+---------------------------+\r\n| id | user_id | title                | deleted_at                | created_at                | updated_at                |\r\n+----+---------+----------------------+---------------------------+---------------------------+---------------------------+\r\n| 1  | 3       | \u697d\u3057\u3044\u4f11\u65e5\u306e\u904e\u3054\u3057\u65b9 | 2017-05-01 18:37:00 +0900 | 2017-04-27 00:29:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 2  | 2       | \u5148\u65e5\u306e\u65c5\u884c\u3067\u306e\u8a71     | 2017-05-16 18:38:00 +0900 | 2017-05-01 08:04:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 8  | 2       | \u30e9\u30f3\u30cb\u30f3\u30b0\u306e\u30b3\u30c4     |                           | 2017-05-02 18:18:00 +0900 | 2017-07-10 01:43:32 +0900 |\r\n+----+---------+----------------------+---------------------------+---------------------------+---------------------------+\r\n3 rows in set<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001where\u304c\u9069\u5fdc\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u7d9a\u3044\u3066\u3001<span style=\"color: #339966\"><strong>order<\/strong><\/span>\u3067\u3059\u3002<\/p>\n<p>app\/models\/post.rb\u306b\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[app\/models\/post.rb\u306b\u5165\u529b\u3059\u308b\u5185\u5bb9]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">scope :desc, -&gt; { order(&quot;posts.created_at DESC&quot;) }<\/pre>\n<p>order\u3092\u4f7f\u3063\u3066\u5b9a\u7fa9\u3057\u305fscope\u3092\u4f7f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<br \/>\nrails console\u3067\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u8d77\u52d5\u3057\u305f\u5f8c\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[desc\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u3059]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">Hirb.enable #\u8868\u5f62\u5f0f\u3067\u51fa\u529b\r\nPost.desc<\/pre>\n<p><span style=\"color: #0000ff\"><strong>[\u5b9f\u884c\u7d50\u679c]<\/strong><\/span><\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \"> Post Load (2.2ms)  SELECT &quot;posts&quot;.* FROM &quot;posts&quot; ORDER BY posts.created_at DESC\r\n+----+---------+------------------------+---------------------------+---------------------------+---------------------------+\r\n| id | user_id | title                  | deleted_at                | created_at                | updated_at                |\r\n+----+---------+------------------------+---------------------------+---------------------------+---------------------------+\r\n| 6  | 5       | \u53cb\u4eba\u304c\u7d50\u5a5a\u3057\u307e\u3057\u305f     |                           | 2017-06-08 22:00:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 5  | 4       | \u53cb\u4eba\u304c\u7d50\u5a5a\u3057\u307e\u3057\u305f     |                           | 2017-05-29 23:40:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 4  | 6       | \u5c71\u767b\u308a\u306b\u884c\u304d\u307e\u3057\u305f     |                           | 2017-05-27 21:37:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 3  | 1       | \u6628\u65e5\u306e\u51fa\u6765\u4e8b           |                           | 2017-05-24 22:02:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 7  | 4       | \u6700\u8fd1\u5c11\u3057\u6c17\u306b\u306a\u3063\u305f\u3053\u3068 |                           | 2017-05-16 18:38:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 8  | 2       | \u30e9\u30f3\u30cb\u30f3\u30b0\u306e\u30b3\u30c4       |                           | 2017-05-02 18:18:00 +0900 | 2017-07-10 01:43:32 +0900 |\r\n| 2  | 2       | \u5148\u65e5\u306e\u65c5\u884c\u3067\u306e\u8a71       | 2017-05-16 18:38:00 +0900 | 2017-05-01 08:04:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 1  | 3       | \u697d\u3057\u3044\u4f11\u65e5\u306e\u904e\u3054\u3057\u65b9   | 2017-05-01 18:37:00 +0900 | 2017-04-27 00:29:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n+----+---------+------------------------+---------------------------+---------------------------+---------------------------+\r\n8 rows in set<\/pre>\n<p>order\u3067\u6307\u5b9a\u3057\u305fcreated_at\u306e\u964d\u9806\u3067<span style=\"color: #0000ff\"><strong>\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u305b\u307e\u3057\u305f\u3002<\/strong><\/span><\/p>\n<h3>\u30d1\u30e9\u30e1\u30fc\u30bf\u4ed8\u304d\u306escope\u306e\u4f7f\u3044\u65b9<\/h3>\n<p>\u307e\u305f\u3001scope\u306b\u306f<span style=\"color: #339966\"><strong>\u30d1\u30e9\u30e1\u30fc\u30bf<\/strong><\/span>\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3064\u307e\u308a\u3001\u30e9\u30e0\u30c0\u5f0f\u306b\u5f15\u6570\u3092\u4ed8\u3051\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092app\/models\/user.rb\u306b\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n<span style=\"color: #0000ff\"><strong>[app\/models\/user.rb\u306b\u5165\u529b\u3059\u308b\u5185\u5bb9]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">scope :age_check, -&gt;(number) { where(&quot;age &lt; ?&quot;, number) }<\/pre>\n<p>\u3053\u308c\u3067scope\u304c\u8a2d\u5b9a\u3067\u304d\u305f\u306e\u3067\u3001rails console\u3067\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u958b\u3044\u3066\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[\u8a2d\u5b9a\u3057\u305fage\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3063\u3066\u307f\u308b]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">Hirb.enable #\u8868\u5f62\u5f0f\u3067\u51fa\u529b\r\nUser.age_check(50)<\/pre>\n<p><span style=\"color: #0000ff\"><strong>[\u5b9f\u884c\u7d50\u679c]<\/strong><\/span><\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \">User Load (0.4ms)  SELECT &quot;users&quot;.* FROM &quot;users&quot; WHERE (age &lt; 50)\r\n+----+----------+-----+---------------------------+---------------------------+\r\n| id | name     | age | created_at                | updated_at                |\r\n+----+----------+-----+---------------------------+---------------------------+\r\n| 1  | \u5c71\u7530\u82b1\u5b50 | 3   | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n| 2  | \u9577\u702c\u6765   | 27  | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n| 3  | \u5b89\u7530\u4e00\u90ce | 11  | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n| 4  | \u7d30\u7530\u4fca\u4ecb | 34  | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n+----+----------+-----+---------------------------+---------------------------+\r\n4 rows in set<\/pre>\n<p>50\u3092\u5f15\u304d\u6570\u3068\u3057\u3066\u6e21\u3057\u305f\u306e\u3067\u3001age\u304c50\u3088\u308a\u3082\u5c0f\u3055\u3044user\u304c\u53d6\u308a\u51fa\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8a2d\u5b9a\u3059\u308b\u3053\u3068\u3067\u3001<span style=\"color: #0000ff\"><strong>\u3088\u308a\u67d4\u8edf\u306b\u4f7f\u3048\u308b\u30e1\u30bd\u30c3\u30c9<\/strong><\/span>\u3092\u5b9a\u7fa9\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>default_scope\u306e\u4f7f\u3044\u65b9<\/h3>\n<p><span style=\"color: #339966\"><strong>default_scope<\/strong><\/span>\u3092\u4f7f\u3048\u3070\u3001\u30e2\u30c7\u30eb\u306b\u8a2d\u5b9a\u3057\u305fscope\u3092\u53cd\u6620\u3057\u305f\u7d50\u679c\u3092\u5e38\u306b\u51fa\u529b\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u3066\u3059\u304c\u3001defall_scope\u306f<span style=\"color: #ff0000\"><strong>\u5e38\u306b\u547c\u3070\u308c\u308b\u3088\u3046\u306b\u306a\u308b<\/strong><\/span>\u306e\u3067\u3001\u4f7f\u7528\u4e0a\u306e\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306fPost\u3067\u524a\u9664\u3055\u308c\u305f\u8a18\u4e8b\u3092\u8868\u793a\u3055\u305b\u306a\u3044\u3088\u3046\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[app\/modes\/post.rb\u306bdefault_scope\u3092\u8a2d\u5b9a]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">default_scope { where(deleted_at:nil) } <\/pre>\n<p>\u3053\u308c\u3067\u3001deleted_at\u306b\u65e5\u4ed8\u304c\u5165\u529b\u3055\u308c\u3066\u3044\u308b\u30ec\u30b3\u30fc\u30c9\u306f\u8868\u793a\u3055\u308c\u306a\u304f\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u5b9f\u969b\u306b\u3059\u3079\u3066\u306ePost\u306e\u30ec\u30b3\u30fc\u30c9\u3092\u53d6\u5f97\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>rails console\u3067\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u8d77\u52d5\u3057\u305f\u5f8c\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[Post\u306e\u4e2d\u8eab\u3092\u5168\u3066\u8868\u793a\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">Hirb.enable #\u8868\u5f62\u5f0f\u3067\u51fa\u529b\r\nPost.all<\/pre>\n<p><span style=\"color: #0000ff\"><strong>[\u5b9f\u884c\u7d50\u679c]<\/strong><\/span><\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \">Post Load (0.4ms)  SELECT &quot;posts&quot;.* FROM &quot;posts&quot; WHERE &quot;posts&quot;.&quot;deleted_at&quot; IS NULL\r\n+----+---------+------------------------+------------+---------------------------+---------------------------+\r\n| id | user_id | title                  | deleted_at | created_at                | updated_at                |\r\n+----+---------+------------------------+------------+---------------------------+---------------------------+\r\n| 3  | 1       | \u6628\u65e5\u306e\u51fa\u6765\u4e8b           |            | 2017-05-24 22:02:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 4  | 6       | \u5c71\u767b\u308a\u306b\u884c\u304d\u307e\u3057\u305f     |            | 2017-05-27 21:37:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 5  | 4       | \u53cb\u4eba\u304c\u7d50\u5a5a\u3057\u307e\u3057\u305f     |            | 2017-05-29 23:40:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 6  | 5       | \u53cb\u4eba\u304c\u7d50\u5a5a\u3057\u307e\u3057\u305f     |            | 2017-06-08 22:00:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 7  | 4       | \u6700\u8fd1\u5c11\u3057\u6c17\u306b\u306a\u3063\u305f\u3053\u3068 |            | 2017-05-16 18:38:00 +0900 | 2017-07-10 01:43:31 +0900 |\r\n| 8  | 2       | \u30e9\u30f3\u30cb\u30f3\u30b0\u306e\u30b3\u30c4       |            | 2017-05-02 18:18:00 +0900 | 2017-07-10 01:43:32 +0900 |\r\n+----+---------+------------------------+------------+---------------------------+---------------------------+\r\n6 rows in set<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u3059\u3079\u3066\u53d6\u5f97\u3057\u3088\u3046\u3068\u3057\u3066\u3082<span style=\"color: #0000ff\"><strong>default_scope\u306e\u52b9\u679c<\/strong><\/span>\u3067delete_at\u306b\u65e5\u4ed8\u304c\u3042\u308b\u8a18\u4e8b\u306f\u8868\u793a\u3055\u308c\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u305f\u3060default_scope\u306f\u6bce\u56de\u547c\u3070\u308c\u308b\u306e\u3067\u3001\u3088\u304f<span style=\"color: #ff0000\"><strong>\u30d0\u30b0\u306e\u539f\u56e0<\/strong><\/span>\u306b\u306a\u3063\u305f\u308a\u3057\u307e\u3059\u3002<\/p>\n<p>\u306a\u306e\u3067\u3001\u4eca\u56de\u306e\u3088\u3046\u306b\u8ad6\u7406\u524a\u9664\u3059\u308b\u5834\u5408\u306a\u3069\u3001<span style=\"color: #ff0000\"><strong>\u4f7f\u3044\u6240\u3092\u9650\u5b9a<\/strong><\/span>\u3057\u3066\u4f7f\u3044\u307e\u3057\u3087\u3046\u3002<\/p>\n<h2>scope\u306e\u5fdc\u7528\u7684\u306a\u4f7f\u3044\u65b9<\/h2>\n<p>\u305d\u308c\u3067\u306f\u5c11\u3057\u5fdc\u7528\u306e\u52b9\u3044\u305fscope\u306e\u4f7f\u3044\u65b9\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<p>\u95a2\u9023\u4ed8\u3051\u3089\u308c\u305f2\u3064\u306e\u30c7\u30fc\u30d6\u30eb\u3092<span style=\"color: #339966\"><strong>joins<\/strong><\/span>\u3067\u5185\u90e8\u7d50\u5408\u3059\u308b\u3068\u304d\u306b\u3001scope\u3067\u306f<span style=\"color: #339966\"><strong>merge<\/strong><\/span>\u30e1\u30bd\u30c3\u30c9\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u5225\u306e\u30e2\u30c7\u30eb\u3067\u8a2d\u5b9a\u3057\u305fscope\u3092\u53c2\u7167\u3057\u3066\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<p>\u4eca\u56de\u306forder\u306e\u8aac\u660e\u3067Post\u30e2\u30c7\u30eb\u306b\u8a2d\u5b9a\u3057\u305fdesc\u30e1\u30bd\u30c3\u30c9\u3092<span style=\"color: #0000ff\"><strong>User\u30e2\u30c7\u30eb\u3067\u4f7f\u3048\u308b\u3088\u3046\u306b<\/strong><\/span>\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<p>\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092app\/models\/user.rb\u306b\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n<span style=\"color: #0000ff\"><strong>[app\/models\/user.rb\u306b\u5165\u529b\u3059\u308b\u5185\u5bb9]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">  has_many :posts\r\n  scope :desc_posts, -&gt; { joins(:posts).merge(Post.desc) }<\/pre>\n<p>\u6b21\u306bapp\/models\/post.rb\u306b\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[app\/models\/post.rb\u306b\u5165\u529b\u3059\u308b\u5185\u5bb9]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">  belongs_to :user\r\n  scope :desc, -&gt; { order(&quot;posts.created_at DESC&quot;) }<\/pre>\n<p>\u305d\u308c\u3067\u306f\u3001rails console\u3067\u30b3\u30f3\u30bd\u30fc\u30eb\u3092\u8d77\u52d5\u3057\u305f\u5f8c\u3001\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u3092\u5165\u529b\u3057\u3066User\u30e2\u30c7\u30eb\u3067\u8a2d\u5b9a\u3057\u305fscope\u3092\u4f7f\u3063\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p><span style=\"color: #0000ff\"><strong>[desc_posts\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3046\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9]<\/strong><\/span><\/p>\n<pre class=\"lang:ruby decode:true \">Hirb.enable #\u8868\u5f62\u5f0f\u3067\u51fa\u529b\r\nUser.desc_posts<\/pre>\n<p><span style=\"color: #0000ff\"><strong>[\u5b9f\u884c\u7d50\u679c]<\/strong><\/span><\/p>\n<pre class=\"striped:false marking:false ranges:false nums:false nums-toggle:false lang:default decode:true \">SELECT &quot;users&quot;.* FROM &quot;users&quot; INNER JOIN &quot;posts&quot; ON &quot;posts&quot;.&quot;user_id&quot; = &quot;users&quot;.&quot;id&quot; ORDER BY posts.created_at DESC\r\n+----+------------+-----+---------------------------+---------------------------+\r\n| id | name       | age | created_at                | updated_at                |\r\n+----+------------+-----+---------------------------+---------------------------+\r\n| 5  | \u5b89\u539f\u5e84\u4e4b\u52a9 | 88  | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n| 4  | \u7d30\u7530\u4fca\u4ecb   | 34  | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n| 6  | \u4e2d\u6751\u62d3\u90ce   | 81  | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n| 1  | \u5c71\u7530\u82b1\u5b50   | 3   | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n| 4  | \u7d30\u7530\u4fca\u4ecb   | 34  | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n| 2  | \u9577\u702c\u6765     | 27  | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n| 2  | \u9577\u702c\u6765     | 27  | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n| 3  | \u5b89\u7530\u4e00\u90ce   | 11  | 2017-07-10 00:36:51 +0900 | 2017-07-10 00:36:51 +0900 |\r\n+----+------------+-----+---------------------------+---------------------------+\r\n8 rows in set<\/pre>\n<p>Post\u306ecreated_at\u30ab\u30e9\u30e0\u306e\u65e5\u4ed8\u306e\u964d\u9806\u3067\u5185\u90e8\u7d50\u5408\u3057\u3001\u30c7\u30fc\u30bf\u3092\u53d6\u308a\u51fa\u305b\u307e\u3057\u305f\u3002<\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001joins\u3067\u5185\u90e8\u7d50\u5408\u3057\u3066\u5225\u306e\u30e2\u30c7\u30eb\u3067\u5b9a\u7fa9\u3057\u305fscope\u3092\u4f7f\u3046\u3068\u304d\u306f<span style=\"color: #0000ff\"><strong>merge\u3068\u7d44\u307f\u5408\u308f\u305b\u3066<\/strong><\/span>\u4f7f\u3046\u3088\u3046\u306b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>\u3044\u304b\u304c\u3067\u3057\u305f\u3067\u3057\u3087\u3046\u304b\uff1f<\/p>\n<p>\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001scope\u306e\u4f7f\u3044\u65b9\u3092\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002<\/p>\n<p>\u4eca\u56de\u7d39\u4ecb\u3057\u305f\u57fa\u672c\u7684\u306awhere\u3084order\u3092\u4f7f\u3063\u3066scope\u3092\u5b9a\u7fa9\u3059\u308b\u3060\u3051\u3067\u3082\u3001<span style=\"color: #0000ff\"><strong>SQL\u6587\u3092\u30e1\u30bd\u30c3\u30c9\u5316\u3067\u304d\u308b<\/strong><\/span>\u306e\u3067\u958b\u767a\u52b9\u7387\u304c\u4e0a\u304c\u308a\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u9069\u5207\u306a\u30e1\u30bd\u30c3\u30c9\u540d\u3092\u3064\u3051\u308b\u3053\u3068\u3067\u3001\u3088\u308a\u76f4\u611f\u7684\u306b\u30c7\u30fc\u30bf\u3092\u6271\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u306e\u3067\u3001\u4f7f\u3048\u308b\u3068\u3053\u308d\u306f<span style=\"color: #0000ff\"><strong>\u7a4d\u6975\u7684\u306bscope\u3092\u5b9a\u7fa9<\/strong><\/span>\u3057\u3066\u3044\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u3082\u3057scope\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066\u5fd8\u308c\u3066\u3057\u307e\u3063\u305f\u3089\u3053\u306e\u8a18\u4e8b\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u306d\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3093\u306b\u3061\u306f! \u30d5\u30ea\u30fc\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u9577\u702c\u3067\u3059\u3002 \u307f\u306a\u3055\u3093\u306fscope\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u304b\u3002 scope\u3092\u4f7f\u3048\u3070\u3001SQL\u6587\u3092\u30e1\u30bd\u30c3\u30c9\u5316\u3067\u304d\u308b\u306e\u3067\u30c7\u30fc\u30bf\u7ba1\u7406\u3092\u52b9\u7387\u5316\u3067\u304d\u307e\u3059\u3002 \u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001scope\u306e\u4f7f\u3044\u65b9\u306b\u3064\u3044\u3066 \u30fbscope  [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":27063,"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":[14,512],"class_list":["post-26994","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ruby-study","tag-ruby-on-rails","tag-scope"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081 | \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\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081 \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\/26994\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081 | \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\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081 \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\/26994\" \/>\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:author\" 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:43:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/07\/rails_26994.png\" \/>\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\/png\" \/>\n<meta name=\"author\" content=\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/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\\\/26994#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/26994\"},\"author\":{\"name\":\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#\\\/schema\\\/person\\\/e8ca7fd09857a736a25e6b4455a3ab61\"},\"headline\":\"\u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081\",\"datePublished\":\"1970-01-01T00:00:00+00:00\",\"dateModified\":\"2024-05-06T02:43:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/26994\"},\"wordCount\":214,\"publisher\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/26994#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/07\\\/rails_26994.png\",\"keywords\":[\"Ruby on Rails\",\"scope\"],\"articleSection\":[\"Ruby\u5b66\u7fd2\"],\"inLanguage\":\"ja\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/26994\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/26994\",\"name\":\"\u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/26994#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/26994#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/07\\\/rails_26994.png\",\"datePublished\":\"1970-01-01T00:00:00+00:00\",\"dateModified\":\"2024-05-06T02:43:52+00:00\",\"description\":\"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081 \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\\\/26994#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/26994\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/26994#primaryimage\",\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/07\\\/rails_26994.png\",\"contentUrl\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/wp-content\\\/uploads\\\/2017\\\/07\\\/rails_26994.png\",\"width\":700,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/26994#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081\"}]},{\"@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\\\/e8ca7fd09857a736a25e6b4455a3ab61\",\"name\":\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/507c280c5c67d2c11fec4fdba20e5bf1ec2fe91f9deb42d2ec50382778b311bf?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/507c280c5c67d2c11fec4fdba20e5bf1ec2fe91f9deb42d2ec50382778b311bf?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/507c280c5c67d2c11fec4fdba20e5bf1ec2fe91f9deb42d2ec50382778b311bf?s=96&d=mm&r=g\",\"caption\":\"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8\"},\"description\":\"\u3010\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u3011 DX\u8a8d\u5b9a\u53d6\u5f97\u4e8b\u696d\u8005\u306b\u9078\u5b9a\u3055\u308c\u3066\u3044\u308b\u682a\u5f0f\u4f1a\u793eSAMURAI\u306e\u30de\u30fc\u30b1\u30c6\u30a3\u30f3\u30b0\u30fb\u30b3\u30df\u30e5\u30cb\u30b1\u30fc\u30b7\u30e7\u30f3\u90e8\u304c\u904b\u55b6\u3002\u300c\u8cea\u306e\u9ad8\u3044IT\u6559\u80b2\u3092\u3001\u3059\u3079\u3066\u306e\u4eba\u306b\u300d\u3092\u30df\u30c3\u30b7\u30e7\u30f3\u306b\u3001IT\u30fb\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u5b66\u3073\u59cb\u3081\u305f\u521d\u5b66\u8005\u306e\u65b9\u306b\u5411\u3051\u8a18\u4e8b\u3092\u57f7\u7b46\u3002 \u7d2f\u8a08\u6307\u5c0e\u8005\u65704\u4e075,000\u540d\u4ee5\u4e0a\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb\u300c\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u300d\u3001\u7d2f\u8a08\u767b\u9332\u8005\u65701\u4e078,000\u4eba\u4ee5\u4e0a\u306e\u30aa\u30f3\u30e9\u30a4\u30f3\u5b66\u7fd2\u30b5\u30fc\u30d3\u30b9\u300c\u4f8d\u30c6\u30e9\u30b3\u30e4\u300d\u3067\u6271\u3046\u6559\u6750\u958b\u767a\u306e\u30ce\u30a6\u30cf\u30a6\u30012013\u5e74\u306e\u5275\u696d\u304b\u3089\u904b\u55b6\u3067\u5f97\u305f\u77e5\u898b\u306b\u57fa\u3065\u304d\u3001\u8a18\u4e8b\u306e\u57f7\u7b46\u3060\u3051\u3067\u306a\u304f\u7de8\u96c6\u30fb\u76e3\u4fee\u3082\u62c5\u5f53\u3057\u3066\u3044\u307e\u3059\u3002 \u3010\u5c02\u9580\u5206\u91ce\u3011 IT\\\/Web\u958b\u767a\\\/AI\u30fb\u30ed\u30dc\u30c3\u30c8\u958b\u767a\\\/\u30a4\u30f3\u30d5\u30e9\u958b\u767a\\\/\u30b2\u30fc\u30e0\u958b\u767a\\\/AI\\\/Web\u30c7\u30b6\u30a4\u30f3\",\"sameAs\":[\"https:\\\/\\\/www.sejuku.net\\\/\",\"https:\\\/\\\/www.facebook.com\\\/sejuku2013\\\/\",\"https:\\\/\\\/www.instagram.com\\\/samuraiengineer_official\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/samuraijuku\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCCFOQO5aDK0xXam4cUQXT8g\"],\"url\":\"https:\\\/\\\/www.sejuku.net\\\/blog\\\/author\\\/samurai-blog\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","description":"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081 \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\/26994","og_locale":"ja_JP","og_type":"article","og_title":"\u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","og_description":"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081 \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\/26994","og_site_name":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","article_publisher":"https:\/\/www.facebook.com\/sejuku2013","article_author":"https:\/\/www.facebook.com\/sejuku2013\/","article_published_time":"1970-01-01T00:00:00+00:00","article_modified_time":"2024-05-06T02:43:52+00:00","og_image":[{"width":700,"height":400,"url":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/07\/rails_26994.png","type":"image\/png"}],"author":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/samuraijuku","twitter_site":"@samuraijuku","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sejuku.net\/blog\/26994#article","isPartOf":{"@id":"https:\/\/www.sejuku.net\/blog\/26994"},"author":{"name":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8","@id":"https:\/\/www.sejuku.net\/blog\/#\/schema\/person\/e8ca7fd09857a736a25e6b4455a3ab61"},"headline":"\u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081","datePublished":"1970-01-01T00:00:00+00:00","dateModified":"2024-05-06T02:43:52+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sejuku.net\/blog\/26994"},"wordCount":214,"publisher":{"@id":"https:\/\/www.sejuku.net\/blog\/#organization"},"image":{"@id":"https:\/\/www.sejuku.net\/blog\/26994#primaryimage"},"thumbnailUrl":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/07\/rails_26994.png","keywords":["Ruby on Rails","scope"],"articleSection":["Ruby\u5b66\u7fd2"],"inLanguage":"ja"},{"@type":"WebPage","@id":"https:\/\/www.sejuku.net\/blog\/26994","url":"https:\/\/www.sejuku.net\/blog\/26994","name":"\u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081 | \u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u30d6\u30ed\u30b0","isPartOf":{"@id":"https:\/\/www.sejuku.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sejuku.net\/blog\/26994#primaryimage"},"image":{"@id":"https:\/\/www.sejuku.net\/blog\/26994#primaryimage"},"thumbnailUrl":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/07\/rails_26994.png","datePublished":"1970-01-01T00:00:00+00:00","dateModified":"2024-05-06T02:43:52+00:00","description":"\u3053\u306e\u8a18\u4e8b\u3067\u306f\u300c \u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081 \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\/26994#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sejuku.net\/blog\/26994"]}]},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.sejuku.net\/blog\/26994#primaryimage","url":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/07\/rails_26994.png","contentUrl":"https:\/\/www.sejuku.net\/blog\/wp-content\/uploads\/2017\/07\/rails_26994.png","width":700,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/www.sejuku.net\/blog\/26994#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sejuku.net\/blog\/"},{"@type":"ListItem","position":2,"name":"\u3010Rails\u5165\u9580\u3011scope\u306e\u4f7f\u3044\u65b9\u307e\u3068\u3081"}]},{"@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\/e8ca7fd09857a736a25e6b4455a3ab61","name":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/secure.gravatar.com\/avatar\/507c280c5c67d2c11fec4fdba20e5bf1ec2fe91f9deb42d2ec50382778b311bf?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/507c280c5c67d2c11fec4fdba20e5bf1ec2fe91f9deb42d2ec50382778b311bf?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/507c280c5c67d2c11fec4fdba20e5bf1ec2fe91f9deb42d2ec50382778b311bf?s=96&d=mm&r=g","caption":"\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u7de8\u96c6\u90e8"},"description":"\u3010\u30d7\u30ed\u30d5\u30a3\u30fc\u30eb\u3011 DX\u8a8d\u5b9a\u53d6\u5f97\u4e8b\u696d\u8005\u306b\u9078\u5b9a\u3055\u308c\u3066\u3044\u308b\u682a\u5f0f\u4f1a\u793eSAMURAI\u306e\u30de\u30fc\u30b1\u30c6\u30a3\u30f3\u30b0\u30fb\u30b3\u30df\u30e5\u30cb\u30b1\u30fc\u30b7\u30e7\u30f3\u90e8\u304c\u904b\u55b6\u3002\u300c\u8cea\u306e\u9ad8\u3044IT\u6559\u80b2\u3092\u3001\u3059\u3079\u3066\u306e\u4eba\u306b\u300d\u3092\u30df\u30c3\u30b7\u30e7\u30f3\u306b\u3001IT\u30fb\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u5b66\u3073\u59cb\u3081\u305f\u521d\u5b66\u8005\u306e\u65b9\u306b\u5411\u3051\u8a18\u4e8b\u3092\u57f7\u7b46\u3002 \u7d2f\u8a08\u6307\u5c0e\u8005\u65704\u4e075,000\u540d\u4ee5\u4e0a\u306e\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30b9\u30af\u30fc\u30eb\u300c\u4f8d\u30a8\u30f3\u30b8\u30cb\u30a2\u300d\u3001\u7d2f\u8a08\u767b\u9332\u8005\u65701\u4e078,000\u4eba\u4ee5\u4e0a\u306e\u30aa\u30f3\u30e9\u30a4\u30f3\u5b66\u7fd2\u30b5\u30fc\u30d3\u30b9\u300c\u4f8d\u30c6\u30e9\u30b3\u30e4\u300d\u3067\u6271\u3046\u6559\u6750\u958b\u767a\u306e\u30ce\u30a6\u30cf\u30a6\u30012013\u5e74\u306e\u5275\u696d\u304b\u3089\u904b\u55b6\u3067\u5f97\u305f\u77e5\u898b\u306b\u57fa\u3065\u304d\u3001\u8a18\u4e8b\u306e\u57f7\u7b46\u3060\u3051\u3067\u306a\u304f\u7de8\u96c6\u30fb\u76e3\u4fee\u3082\u62c5\u5f53\u3057\u3066\u3044\u307e\u3059\u3002 \u3010\u5c02\u9580\u5206\u91ce\u3011 IT\/Web\u958b\u767a\/AI\u30fb\u30ed\u30dc\u30c3\u30c8\u958b\u767a\/\u30a4\u30f3\u30d5\u30e9\u958b\u767a\/\u30b2\u30fc\u30e0\u958b\u767a\/AI\/Web\u30c7\u30b6\u30a4\u30f3","sameAs":["https:\/\/www.sejuku.net\/","https:\/\/www.facebook.com\/sejuku2013\/","https:\/\/www.instagram.com\/samuraiengineer_official\/","https:\/\/x.com\/https:\/\/twitter.com\/samuraijuku","https:\/\/www.youtube.com\/channel\/UCCFOQO5aDK0xXam4cUQXT8g"],"url":"https:\/\/www.sejuku.net\/blog\/author\/samurai-blog"}]}},"_links":{"self":[{"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/posts\/26994","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\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/comments?post=26994"}],"version-history":[{"count":0,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/posts\/26994\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/media\/27063"}],"wp:attachment":[{"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/media?parent=26994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/categories?post=26994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sejuku.net\/blog\/wp-json\/wp\/v2\/tags?post=26994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}