Nick Sieger: RailsConf 2007 Opening Keynote: David Heinemeier Hansson tag:blog.nicksieger.com,2005:Typo Typo 2007-08-31T17:25:39+00:00 Bernd urn:uuid:27a8249e-4cac-4c53-ab38-d43ecaa6b36b 2007-05-21T08:20:22+00:00 2007-08-31T17:25:39+00:00 Comment on RailsConf 2007 Opening Keynote: David Heinemeier Hansson by Bernd <p>Ha, I haven&#8217;t even learned 1,2.3 and yet curious to see 2.0 :-)</p> Akhil Bansal urn:uuid:49b01920-31ba-4921-8311-c47ed550e0fa 2007-05-20T04:39:03+00:00 2007-08-31T17:25:39+00:00 Comment on RailsConf 2007 Opening Keynote: David Heinemeier Hansson by Akhil Bansal <p>Hey, Lots of new things to come in Rails2.0, Thanks for sharing.</p> Logan Koester urn:uuid:cec5ca3f-7629-4bb9-89bf-2512d53e36e6 2007-05-19T07:33:02+00:00 2007-08-31T17:25:39+00:00 Comment on RailsConf 2007 Opening Keynote: David Heinemeier Hansson by Logan Koester <p>Indeed, thank you.</p> D. Taylor Singletary urn:uuid:c909cdab-454b-4ce2-a41a-b2b962087d8e 2007-05-18T18:00:33+00:00 2007-08-31T17:25:40+00:00 Comment on RailsConf 2007 Opening Keynote: David Heinemeier Hansson by D. Taylor Singletary <p>Thanks for summarizing this for those of us who couldn&#8217;t make it to the keynote.</p> Nick Sieger urn:uuid:35f07fbf-9a1b-4848-9e0a-848ba7029697 2007-05-18T17:10:39+00:00 2007-08-31T17:25:40+00:00 RailsConf 2007 Opening Keynote: David Heinemeier Hansson <h1>Rails 2.0</h1> <h2>Where we&#8217;ve been</h2> <p>David is surprised and proud of the community that we already have, and wants us to be comfortable with where we are, and not always looking toward the future. We have:</p> <ul> <li>Million gem downloads</li> <li>Hundreds of plugins</li> <li>10k users on the rubyonrails-talk mailing list</li> <li>Ruby job descriptions (asking for 3 years RoR experience, longer than David)</li> <li><a href="http://www.amazon.com/s/002-0555878-2213644?ie=UTF8&amp;tag=mozilla-20&amp;index=blended&amp;link%5Fcode=qs&amp;field-keywords=ruby%20on%20rails&amp;sourceid=Mozilla-search">Books, books, books</a> (and not just English books, but non-English titles as well), surpassing VBA, Perl, and Python in book sales</li> <li>IDEs from NetBeans, Borland, Aptana, etc.</li> </ul> <p>Rails 2.0 is not going to be the &#8220;Unicorn&#8221;. It&#8217;s not going to be a total rewrite, it actually has a release schedule, it will not break backwards-compatibility. Instead, it will build upon what we already have, and continue the philosophy of building on what is useful and needed. In fact, 95% of what&#8217;s in 2.0 already works today, in the edge. Example, a simple controller that handles three formats of input/output, with a person resource for accessing the data from a remote server.</p> <div class="typocode"><pre><code class="typocode_ruby "><span class="keyword">class </span><span class="class">PeopleController</span> <span class="punct">&lt;</span> <span class="constant">ApplicationController</span> <span class="punct">...</span> <span class="keyword">def </span><span class="method">create</span> <span class="attribute">@person</span> <span class="punct">=</span> <span class="constant">Person</span><span class="punct">.</span><span class="ident">create</span><span class="punct">(...)</span> <span class="ident">respond_to</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">format</span><span class="punct">|</span> <span class="ident">format</span><span class="punct">.</span><span class="ident">html</span> <span class="punct">{</span> <span class="ident">redirect_to</span> <span class="ident">person_url</span><span class="punct">(</span><span class="attribute">@person</span><span class="punct">)</span> <span class="punct">}</span> <span class="ident">format</span><span class="punct">.</span><span class="ident">xml</span> <span class="punct">{</span> <span class="ident">render</span> <span class="symbol">:status</span> <span class="punct">=&gt;</span> <span class="symbol">:created</span><span class="punct">,</span> <span class="symbol">:location</span> <span class="punct">=&gt;</span> <span class="ident">person_url</span><span class="punct">(</span><span class="attribute">@person</span><span class="punct">),</span> <span class="punct">...</span> <span class="punct">}</span> <span class="ident">format</span><span class="punct">.</span><span class="ident">js</span> <span class="punct">{</span> <span class="ident">render</span> <span class="symbol">:update</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">js</span><span class="punct">|</span> <span class="punct">...</span> <span class="keyword">end</span> <span class="punct">}</span> <span class="keyword">end</span> <span class="keyword">end</span> <span class="keyword">end</span> <span class="keyword">class </span><span class="class">Person</span> <span class="punct">&lt;</span> <span class="constant">ActiveResource</span><span class="punct">::</span><span class="constant">Base</span> <span class="constant">self</span><span class="punct">.</span><span class="ident">site</span> <span class="punct">=</span> <span class="punct">&quot;</span><span class="string">http://example.com/</span><span class="punct">&quot;</span> <span class="keyword">end</span></code></pre></div> <p>David then goes into a live demo of the new scaffold resource, which by appearance is identical to the old scaffolding, except it comes pre-baked with a REST-ful XML interface. He then adds support for a text format with a couple of lines of code, jumps into IRB, defines an active resource, and proceeds to change the data remotely.</p> <p>If you want to add search to your controller, you can do it in a DRY way, and all the format/view work you&#8217;ve done will benefit:</p> <div class="typocode"><pre><code class="typocode_ruby "><span class="keyword">class </span><span class="class">PeopleController</span> <span class="punct">&lt;</span> <span class="constant">ApplicationController</span> <span class="keyword">def </span><span class="method">index</span> <span class="keyword">if</span> <span class="ident">params</span><span class="punct">[</span><span class="symbol">:name</span><span class="punct">]</span> <span class="attribute">@people</span> <span class="punct">=</span> <span class="constant">Person</span><span class="punct">.</span><span class="ident">find</span> <span class="symbol">:all</span><span class="punct">,</span> <span class="symbol">:conditions</span> <span class="punct">=&gt;</span> <span class="punct">[&quot;</span><span class="string">name like ?</span><span class="punct">&quot;,</span> <span class="punct">&quot;</span><span class="string"><span class="expr">#{params[:name]}</span>%</span><span class="punct">&quot;]</span> <span class="keyword">else</span> <span class="attribute">@people</span> <span class="punct">=</span> <span class="constant">Person</span><span class="punct">.</span><span class="ident">find</span> <span class="symbol">:all</span> <span class="keyword">end</span> <span class="punct">...</span> <span class="keyword">end</span> <span class="keyword">end</span></code></pre></div> <p>David points out that 37signals, Shopify, Fluxiom, et. al. are real sites, with non-trivial domains that are still well executed in Rails, so it&#8217;s not just about simple scaffolding demos.</p> <p>In Rails 2.0, ActiveResource will be bundled with Rails, and ActionWebService will not.</p> <h2>Friends of Rails</h2> <ul> <li>AJAX!</li> <li>REST!</li> <li>Atom? &#8211; Atom should be more native to Rails</li> <li>Openid? &#8211; Openid is not necessarily something that needs to be used by all, but still a strong ally.</li> </ul> <h2>9 other things I like about Rails 2</h2> <ul> <li>Breakpoints are back &#8211; no longer depends on <code>Binding.of_caller</code>; instead Rails depends and builds upon <a href="http://rubyforge.org/projects/ruby-debug/"><code>ruby-debug</code></a> by Kent Sibilev.</li> <li>HTTP Performance &#8211; streamlining .js and .css, even though it feels better to break up Javascript and CSS into many little pieces, and gzip them</li> </ul> <div class="typocode"><pre><code class="typocode_ruby "><span class="punct">&lt;%=</span><span class="string"> javascript_include_tag :all, :cache </span><span class="punct">=&gt;</span> <span class="constant">true</span> <span class="punct">%&gt;</span><span class="string"> &lt;%= stylesheet_link_tag :all, :cache =</span><span class="punct">&gt;</span> <span class="constant">true</span> <span class="punct">%&gt;</span><span class="string"></span></code></pre></div> <p>We can also fake out the browser and configure multiple asset hosts (4) you can maximize browser connections</p> <div class="typocode"><pre><code class="typocode_ruby "><span class="ident">config</span><span class="punct">.</span><span class="ident">action_controller</span><span class="punct">.</span><span class="ident">asset_host</span> <span class="punct">=</span> <span class="punct">'</span><span class="string">assets%d.highrisehq.com</span><span class="punct">'</span></code></pre></div> <ul> <li>Query cache</li> </ul> <div class="typocode"><pre><code class="typocode_ruby "><span class="constant">ActiveRecord</span><span class="punct">::</span><span class="constant">Base</span><span class="punct">.</span><span class="ident">cache</span> <span class="keyword">do</span> <span class="comment"># actions here are cached</span> <span class="keyword">end</span></code></pre></div> <ul> <li>Rendering and MIME types &#8211; bake the MIME convention into the template, and separate from the rendering mechanism people/index.html.erb people/index.xml.builder people/index.rss.erb people/index.atom.builder</li> <li>config/initializers replacing config/environment. Initializers are .rb files in the config/initializers directory of your app that are automatically loaded during initialization time.</li> <li>Sexy migrations</li> </ul> <div class="typocode"><pre><code class="typocode_ruby "><span class="ident">create_table</span> <span class="symbol">:people</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">t</span><span class="punct">|</span> <span class="ident">t</span><span class="punct">.</span><span class="ident">integer</span> <span class="symbol">:account_id</span> <span class="ident">t</span><span class="punct">.</span><span class="ident">string</span> <span class="symbol">:first_name</span><span class="punct">,</span> <span class="symbol">:last_name</span><span class="punct">,</span> <span class="symbol">:null</span> <span class="punct">=&gt;</span> <span class="constant">false</span> <span class="ident">t</span><span class="punct">.</span><span class="ident">text</span> <span class="symbol">:description</span> <span class="ident">t</span><span class="punct">.</span><span class="ident">timestamps</span> <span class="keyword">end</span></code></pre></div> <ul> <li>HTTP authentication (<code>authenticate_or_request_with_http_basic</code>, <code>authenticate_with_http_basic</code>)</li> <li>The MIT assumption &#8211; the licensing question &#8211; make it easier to understand</li> <li>Spring cleaning &#8211; getting rid of the cruft &#8211; stay tuned!</li> </ul>