{"id":389,"date":"2007-11-17T08:03:45","date_gmt":"2007-11-17T12:03:45","guid":{"rendered":"http:\/\/www.dr-chuck.com\/wordpress\/?p=389"},"modified":"2011-12-17T12:24:27","modified_gmt":"2011-12-17T16:24:27","slug":"little-things-i-love-about-rails-this-time-activerecord","status":"publish","type":"post","link":"https:\/\/www.dr-chuck.com\/csev-blog\/2007\/11\/little-things-i-love-about-rails-this-time-activerecord\/","title":{"rendered":"Little Things I love about Rails &#8211; This Time ActiveRecord"},"content":{"rendered":"<p>When you are setting a foreign key in an object you can do it using the id directly or through the helper method.  In this example comments belong_to users.<\/p>\n<pre><code>\n# Using an object reference\nu = User.get(1234)\nc = Comment.new\nc.user = u\n# Old school\nx = Comment.new\nx.user_id = 1234\n<\/code>\n<\/pre>\n<p>Yeah &#8211; that is what I like to see &#8211; a framework that respects programmer intelligence and gives us choices!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When you are setting a foreign key in an object you can do it using the id directly or through the helper method. In this example comments belong_to users. # Using an object reference u = User.get(1234) c = Comment.new c.user = u # Old school x = Comment.new x.user_id = 1234 Yeah &#8211; that [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-389","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/389","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/comments?post=389"}],"version-history":[{"count":1,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/389\/revisions"}],"predecessor-version":[{"id":2488,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/389\/revisions\/2488"}],"wp:attachment":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/media?parent=389"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/categories?post=389"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/tags?post=389"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}