Nick Sieger: RailsConf Europe: David Heinemeier Hanssontag:blog.nicksieger.com,2005:TypoTypo2010-11-22T18:43:19+00:00Pratikurn:uuid:b24da1c9-af02-479d-bb15-9dad45779b132007-09-21T10:24:22+00:002010-11-22T18:43:19+00:00Comment on RailsConf Europe: David Heinemeier Hansson by Pratik<p>David just used iPhone as an example. Rails doesn’t have “optimization” done for iPhone speicifically. The main idea is, you can set the fomat using request.format= based on any request env params. For example, it can be used to do some specific rendering for r’tard IE in just the same way.</p>
<p>Another thing he missed was, when you set content_type => Mime::HTML, rails will use layout.html.erb as layout.</p>Jon Arbuckleurn:uuid:7341b536-ee79-442f-8bc2-0a6121406d792007-09-21T10:01:54+00:002010-11-22T18:43:19+00:00Comment on RailsConf Europe: David Heinemeier Hansson by Jon Arbuckle<p>@Michael</p>
<p>That is because in the Rails world, it is uncool to use anything not made by Apple (unless Apple is not in that market). You should know this by now.</p>Michaelurn:uuid:0b9ced1e-b390-4d7c-bcd9-61c68c575b812007-09-18T19:50:12+00:002010-11-22T18:43:19+00:00Comment on RailsConf Europe: David Heinemeier Hansson by Michael<p>Why optimize just for the IPhone? There are a lot of phones/devices out there. Why not make it so it’ll work on all devices that supports a certain level of html+css etc? </p>
<p>Opera Mobile and Opera Mini can display any page on almost any device. Why not try your application on that today?
<a href='http://www' rel="nofollow">http://www</a>.operamini.com/beta/simulator/</p>Benurn:uuid:d6979bb9-2781-430b-92a9-6dc681d94a062007-09-18T16:26:49+00:002010-11-22T18:43:20+00:00Comment on RailsConf Europe: David Heinemeier Hansson by Ben<p>I’m liking the custom layouts, such as the iPhone example. With the announcement of the UK iPhone launch today I can’t wait to work on an optimised version of my Rails app.</p>Nickurn:uuid:6152a27e-e5c5-4303-8f9c-4d9974eb4b2c2007-09-18T14:15:58+00:002010-11-22T18:43:20+00:00Comment on RailsConf Europe: David Heinemeier Hansson by Nick<p>Even better! Thanks for the clarification.</p>Pratikurn:uuid:fb705557-e96b-455c-9fae-e84dfd9957712007-09-18T09:10:31+00:002010-11-22T18:43:20+00:00Comment on RailsConf Europe: David Heinemeier Hansson by Pratik<p>Verified patch report is empty because all the patches are applied very soon they become verified. </p>
<p>So, an empty report is not scarse, it’s just a sign of success!</p>Nick Siegerurn:uuid:b1cf2100-7876-4946-9082-8b8054a24bd32007-09-18T08:14:00+00:002010-11-22T18:43:20+00:00RailsConf Europe: David Heinemeier Hansson<h2>Rebel With a Cause</h2>
<p>Rails is no longer the James Dean character, looking outward, trying to convince you of something. It’s no longer about a rebellion or a revolution. Instead, Rails is settling in as a passionate, inward-looking craftsperson.</p>
<p>After the rebellion, settle in and enjoy the results of your work. David hasn’t been working directly on Rails too much, instead he’s been enjoying it.</p>
<p>And it’s not about David anymore. It’s about You (cue the Time Person of the Year cover). David wants Rails to be more friendly to newcomers.</p>
<p><a href="http://dev.rubyonrails.org/report/12">Report #12: Verified Patches</a>. Encouraging the community to approve patches, rather than limiting the decisions to the core. Opening up Rails. (Also, unfortunately looking a little scarce at the moment. <em>Update: turns out it’s empty because patches are quickly applied, not because there aren’t any submitted!</em>)</p>
<p>David screened the original Rails movie -- showing Apache setup, manually creating databases and tables. He quickly lost patience for it.</p>
<p>Compare to the current state of the art, with everything down to the routes and migrations gets created for you, lowering the barrier to entry (example: a new rake task <code>db:create:all</code>).</p>
<p>Rails 2.0 is largely about continual improvement and removing the cruft:</p>
<ul>
<li>Cookie-based session store as the default</li>
<li>Routing: <code>map.root</code></li>
<li>Removing the dynamic <code>scaffold :posts</code> feature</li>
<li><code>map.namespace</code> and <code>script/generate controller admin::posts</code></li>
<li><code>*.html.erb</code> files with the MIME type and renderer baked into the filename, since the two are now mutually exclusive.</li>
<li>Automatically named partials with <code>render :partial => @posts</code> resolving to <code>_post.html.erb</code></li>
<li>Namespacing and named routes:</li>
</ul>
<div class="typocode"><pre><code class="typocode_ruby "><span class="ident">mop</span><span class="punct">.</span><span class="ident">namespace</span> <span class="symbol">:admin</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">admin</span><span class="punct">|</span>
<span class="ident">admin</span><span class="punct">.</span><span class="ident">resources</span> <span class="symbol">:posts</span>
<span class="keyword">end</span>
<span class="comment"># ...</span>
<span class="ident">link_to</span> <span class="punct">'</span><span class="string">Show</span><span class="punct">',</span> <span class="punct">[</span><span class="symbol">:admin</span><span class="punct">,</span> <span class="ident">post</span><span class="punct">]</span></code></pre></div>
<ul>
<li>HTTP authentication</li>
</ul>
<div class="typocode"><pre><code class="typocode_ruby "><span class="keyword">class </span><span class="class">Admin::PostsController</span> <span class="punct"><</span> <span class="constant">ApplicationController</span>
<span class="ident">before_filter</span> <span class="symbol">:ensure_administrator</span>
<span class="comment"># ...</span>
<span class="ident">private</span>
<span class="keyword">def </span><span class="method">ensure_administrator</span>
<span class="ident">authenticate_or_request_with_http_basic</span><span class="punct">("</span><span class="string">Blog Admin</span><span class="punct">")</span> <span class="keyword">do</span> <span class="punct">|</span><span class="ident">user</span><span class="punct">,</span><span class="ident">pass</span><span class="punct">|</span>
<span class="ident">username</span> <span class="punct">==</span> <span class="punct">"</span><span class="string">dhh</span><span class="punct">"</span> <span class="punct">&&</span> <span class="ident">password</span> <span class="punct">==</span> <span class="punct">"</span><span class="string">123</span><span class="punct">"</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
<span class="keyword">end</span></code></pre></div>
<ul>
<li>Custom layouts for specific user agents (say, oh, the iPhone). Views can also be rendered, e.g., <code>index.iphone.erb</code>.</li>
</ul>
<div class="typocode"><pre><code class="typocode_ruby "><span class="keyword">class </span><span class="class">ApplicationController</span> <span class="punct"><</span> <span class="constant">ActionController</span><span class="punct">::</span><span class="constant">Base</span>
<span class="ident">before_filter</span> <span class="symbol">:adjust_format_for_iphone</span>
<span class="keyword">def </span><span class="method">adjust_format_for_iphone</span>
<span class="keyword">if</span> <span class="ident">request</span><span class="punct">.</span><span class="ident">env</span><span class="punct">["</span><span class="string">HTTP_USER_AGENT</span><span class="punct">"][/</span><span class="regex">iPhone</span><span class="punct">/]</span>
<span class="ident">request</span><span class="punct">.</span><span class="ident">format</span> <span class="punct">=</span> <span class="symbol">:iphone</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
<span class="keyword">end</span>
<span class="comment"># initializer</span>
<span class="constant">Mime</span><span class="punct">::</span><span class="constant">Type</span><span class="punct">.</span><span class="ident">register</span> <span class="punct">"</span><span class="string">application/x-iphone</span><span class="punct">",</span> <span class="symbol">:iphone</span>
<span class="comment"># In a controller method</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">iphone</span> <span class="punct">{</span> <span class="ident">render</span> <span class="symbol">:text</span> <span class="punct">=></span> <span class="punct">"</span><span class="string">Hello iPhone</span><span class="punct">",</span> <span class="symbol">:content</span> <span class="punct">=></span> <span class="constant">Mime</span><span class="punct">::</span><span class="constant">HTML</span> <span class="punct">}</span>
<span class="keyword">end</span></code></pre></div>
<ul>
<li><code>atom_feed_helper</code>, a new plugin -- builder for Atom specified in <code>index.atom.builder</code></li>
<li><code><%= yield :head %></code>, <code>content_for :head { auto_discovery_link(:atom, formatted_posts_url)}</code></li>
<li>Debugger -- allows you to be lazy and leave your <code>breakpoint</code>s in your production code, not that you’d actually want to do that. Dumps you into irb where you can inspect variables, etc. but you can also drop down another level to see the call hierarchy, etc.</li>
</ul>
<p>So when will we see Rails 2.0? The preview release is coming, hopefully before conference end.</p>