<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>chuyeow.wtf</title>
  <subtitle>Go, Ruby, Rails, Firefox, Anime, Mac</subtitle>
  <link rel="self" type="application/atom+xml" href="https://chuyeow.wtf/categories/edge-rails/feed.xml"/>
  <link rel="alternate" type="text/html" href="https://chuyeow.wtf"/>
  <generator uri="https://www.getzola.org/">Zola</generator>
  <updated>2008-05-25T19:06:36+00:00</updated>
  <id>https://chuyeow.wtf/categories/edge-rails/feed.xml</id>
  <entry>
    <title>Living on the edge (of Rails) #22 - pre-Railsconf 2008 edition</title>
    <published>2008-05-25T19:06:36+00:00</published>
    <updated>2008-05-25T19:06:36+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/05/25/living-on-the-edge-of-rails-22-pre-railsconf-2008-edition/"/>
    <id>https://chuyeow.wtf/2008/05/25/living-on-the-edge-of-rails-22-pre-railsconf-2008-edition/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/05/25/living-on-the-edge-of-rails-22-pre-railsconf-2008-edition/">&lt;p&gt;No mind-blowing changes in Rails this week prior to RailsConf - as Gregg mentioned last week in the &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;2008&#x2F;5&#x2F;21&#x2F;rails-envy-podcast-episode-032&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt;, it&#x27;s pre-2.1 days (Rails 2.1 will &lt;em&gt;probably&lt;&#x2F;em&gt; be released at RailsConf) so it&#x27;s pretty easy to see why. Oh and all Rails tests now pass in Ruby 1.9 after a long-standing &lt;code&gt;#module_eval&lt;&#x2F;code&gt; bug got fixed in Ruby 1.9&#x27;s trunk (see &lt;a href=&quot;http:&#x2F;&#x2F;groups.google.com&#x2F;group&#x2F;ruby-core-google&#x2F;browse_thread&#x2F;thread&#x2F;6d08e11363bf49b4&quot;&gt;thread&lt;&#x2F;a&gt; for more details).&lt;&#x2F;p&gt;
&lt;p&gt;I&#x27;ll be at (my first) Railsconf 2008 in Portland, Oregon this Thursday onwards - if anyone sees me and recognizes me from my &lt;a href=&quot;http:&#x2F;&#x2F;www.facebook.com&#x2F;people&#x2F;Chu_Yeow&#x2F;500115784&quot;&gt;Facebook picture&lt;&#x2F;a&gt; please come and say hi (no head butting though).&lt;&#x2F;p&gt;
&lt;p&gt;This week’s report covers changes from 19th May 2008 to 25th May 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;first and last methods now work with associations and named_scope&lt;&#x2F;h3&gt;
&lt;p&gt;Remember how the &lt;a href=&quot;https:&#x2F;&#x2F;chuyeow.wtf&#x2F;2008&#x2F;04&#x2F;05&#x2F;living-on-the-edge-of-rails-14-the-extreme-edition-extremely-late&#x2F;&quot;&gt;merging of the has_finder gem into Rails&lt;&#x2F;a&gt; allowed you to do things like &lt;code&gt;Post.first&lt;&#x2F;code&gt; and &lt;code&gt;Post.last&lt;&#x2F;code&gt;?&lt;&#x2F;p&gt;
&lt;p&gt;Now you can go one step further and use the same methods on your ActiveRecord associations. For example:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;post = Post.find(1)
first_comment = post.comments.first&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;If you have a &lt;a href=&quot;http:&#x2F;&#x2F;ryandaigle.com&#x2F;articles&#x2F;2008&#x2F;3&#x2F;24&#x2F;what-s-new-in-edge-rails-has-finder-functionality&quot;&gt;named_scope&lt;&#x2F;a&gt; named &lt;code&gt;recent&lt;&#x2F;code&gt; defined, you can even do this:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;post.comments.recent.last&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This neat little enhancement is courtesy of &lt;a href=&quot;http:&#x2F;&#x2F;railscasts.com&#x2F;&quot;&gt;Ryan Bates&lt;&#x2F;a&gt; (yes, that &lt;em&gt;Ryan Bates&lt;&#x2F;em&gt; of &lt;a href=&quot;http:&#x2F;&#x2F;railscasts.com&#x2F;&quot;&gt;Railscasts&lt;&#x2F;a&gt; fame).&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;73c59638549686fccc749ffd3ac53cb533c5fd61&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;73c59638549686fccc749ffd3ac53cb533c5fd61&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Cache stores now have an exist? method and controllers get fragment_exist?&lt;&#x2F;h3&gt;
&lt;p&gt;The cache stores in Rails (Memcache, file stores, etc.) now have an &lt;code&gt;exist?&lt;&#x2F;code&gt; method that checks whether a cached value exists given a cache key. This allows Rails controllers to expose a &lt;code&gt;fragment_exist?&lt;br &#x2F;&gt;
&lt;&#x2F;code&gt; method that allows you to check for existence of a cache fragment:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;fragment_exist?(&#x27;example.com&#x2F;foo&#x2F;bar&#x27;)&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This little enhancement is courtesy of &lt;a href=&quot;http:&#x2F;&#x2F;josevalim.blogspot.com&#x2F;&quot;&gt;José Valim&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;99860b72aebe0348f41e82d4710343498d89a84b#diff-2&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;99860b72aebe0348f41e82d4710343498d89a84b#diff-2&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Create association records with block argument&lt;&#x2F;h3&gt;
&lt;p&gt;You can now create records for associations like so:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;post.coments.create!(:title =&gt; &#x27;Techcrunch&#x27;) do |c|
  c.body = &quot;Rails can&#x27;t scale&quot;
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This is in keeping with the &lt;a href=&quot;https:&#x2F;&#x2F;chuyeow.wtf&#x2F;2008&#x2F;05&#x2F;04&#x2F;living-on-the-edge-of-rails-19-change_table-for-migrations-and-more&#x2F;&quot;&gt;ActiveRecord::Base.create change previously mentioned&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Credit for this patch goes (once again) to &lt;a href=&quot;http:&#x2F;&#x2F;railscasts.com&#x2F;&quot;&gt;Ryan Bates&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;6cba97d2a449faf21aec9fe9d4434067e414226f&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;6cba97d2a449faf21aec9fe9d4434067e414226f&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series.&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the Edge (of Rails) in Spanish</title>
    <published>2008-05-18T20:16:18+00:00</published>
    <updated>2008-05-18T20:16:18+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/05/18/living-on-the-edge-of-rails-in-spanish/"/>
    <id>https://chuyeow.wtf/2008/05/18/living-on-the-edge-of-rails-in-spanish/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/05/18/living-on-the-edge-of-rails-in-spanish/">&lt;p&gt;&lt;a href=&quot;http:&#x2F;&#x2F;sobrerailes.com&#x2F;&quot;&gt;Juan Lupión&lt;&#x2F;a&gt; wrote in to inform me that he&#x27;s also translating my Living on the Edge (of Rails) series of blog posts to Español. Thanks Juan!&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #21</title>
    <published>2008-05-18T19:54:42+00:00</published>
    <updated>2008-05-18T19:54:42+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/05/18/living-on-the-edge-of-rails-21/"/>
    <id>https://chuyeow.wtf/2008/05/18/living-on-the-edge-of-rails-21/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/05/18/living-on-the-edge-of-rails-21/">&lt;p&gt;It&#x27;s another slow week (just 2 changes of note &lt;acronym title=&quot;in my humble opinion&quot;&gt;imho&lt;&#x2F;acronym&gt;) after the &lt;a href=&quot;http:&#x2F;&#x2F;www.rubyinside.com&#x2F;rails-21-released-891.html&quot;&gt;release of the 1st Release Candidate (RC1) of Rails 2.1&lt;&#x2F;a&gt;. Follow that link for installation instructions - though if you&#x27;re reading this blog post you probably don&#x27;t care! (because you&#x27;re, you know, &quot;living on the edge&quot;). Cheesiness aside, be sure to report any bugs you may encounter when upgrading to 2.1 RC1 or edge at the &lt;a href=&quot;http:&#x2F;&#x2F;rails.lighthouseapp.com&#x2F;projects&#x2F;8994-ruby-on-rails&#x2F;overview&quot;&gt;Rails bug tracker&lt;&#x2F;a&gt; - it is an RC so any bug reports would be very welcome and useful!&lt;&#x2F;p&gt;
&lt;p&gt;This week’s report covers changes from 12th May 2008 to 18th May 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;caches_action can has conditionals&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;caches_action&lt;&#x2F;code&gt; now takes an &lt;code&gt;:if&lt;&#x2F;code&gt; option (just like &lt;a href=&quot;https:&#x2F;&#x2F;chuyeow.wtf&#x2F;2008&#x2F;04&#x2F;20&#x2F;living-on-the-edge-of-rails-17&#x2F;&quot;&gt;caches_page does&lt;&#x2F;a&gt;). For example:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;caches_action :index, :if =&amp;gt; Proc.new { |c| !c.request.format.json? }&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This little enhancement is courtesy of José Valim.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;7708650f73ddb4db300ea2059c60c1d907a4384e&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;7708650f73ddb4db300ea2059c60c1d907a4384e&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Bugfix: :select option is now scanned in ActiveRecord finders to ensure needed tables are included in generated SQL&lt;&#x2F;h3&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;Post.find(:all, :include =&amp;gt; :author, :select =&amp;gt; &#x27;posts.*, authors.id as &quot;author_id&quot;&#x27;, :limit =&amp;gt; 2)&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Would generate an SQL statement like this:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;sql&quot;&gt;SELECT posts.*, authors.id as &quot;author_id&quot; FROM &quot;posts&quot; LIMIT 2&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Notice how the &lt;code&gt;authors&lt;&#x2F;code&gt; table is not joined. This oversight is now fixed.&lt;&#x2F;p&gt;
&lt;p&gt;Thanks go to John Devine for this bugfix.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;b28b54cab090bed8f099ef375b419a8f92390dd4&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;b28b54cab090bed8f099ef375b419a8f92390dd4&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series. Also, if anyone has any recommendations of (non-ruby-related) things to do in Portland, do let me know!&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #20 - script&#x2F;dbconsole and flash.now now test-able</title>
    <published>2008-05-11T14:54:32+00:00</published>
    <updated>2008-05-11T14:54:32+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/05/11/living-on-the-edge-of-rails-20-scriptdbconsole-and-flashnow-now-test-able/"/>
    <id>https://chuyeow.wtf/2008/05/11/living-on-the-edge-of-rails-20-scriptdbconsole-and-flashnow-now-test-able/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/05/11/living-on-the-edge-of-rails-20-scriptdbconsole-and-flashnow-now-test-able/">&lt;p&gt;This week’s report covers changes from 5th May 2008 to 11th May 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;script&#x2F;dbconsole&lt;&#x2F;h3&gt;
&lt;p&gt;A &lt;code&gt;script&#x2F;dbconsole&lt;&#x2F;code&gt; script has been added that allows you to connect to your database using its console client.&lt;&#x2F;p&gt;
&lt;p&gt;If you needed to connect to your production MySQL database (you better know what you are doing!), for example, you can run &lt;code&gt;RAILS_ENV=production script&#x2F;dbconsole&lt;&#x2F;code&gt; or simply &lt;code&gt;script&#x2F;dbconsole production&lt;&#x2F;code&gt; (thanks to &lt;a href=&quot;http:&#x2F;&#x2F;railscasts.com&#x2F;&quot;&gt;Ryan Bates&lt;&#x2F;a&gt; for pointing this out!) and it will login to your database server using the command line MySQL client. This also works with the PostgreSQL and SQLite databases.&lt;&#x2F;p&gt;
&lt;p&gt;To use this script in your Rails app, remember to run &lt;code&gt;rake rails:update:scripts&lt;&#x2F;code&gt; after updating to edge Rails.&lt;&#x2F;p&gt;
&lt;p&gt;This nice little enhancement courtesy of &lt;a href=&quot;http:&#x2F;&#x2F;www.sanityinc.com&#x2F;&quot;&gt;Steve Purcell&lt;&#x2F;a&gt;, who originally had a similar &lt;a href=&quot;http:&#x2F;&#x2F;www.sanityinc.com&#x2F;articles&#x2F;rails-db-console&quot;&gt;database console plugin&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;4a07103687084496b773e18a03b1f2f5e686f7ad&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;4a07103687084496b773e18a03b1f2f5e686f7ad&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;flash.now is now accessible in tests&lt;&#x2F;h3&gt;
&lt;p&gt;This is something that &lt;a href=&quot;http:&#x2F;&#x2F;www.pluitsolutions.com&#x2F;2008&#x2F;01&#x2F;22&#x2F;testing-flashnow-in-rails&#x2F;&quot;&gt;many&lt;&#x2F;a&gt; &lt;a href=&quot;http:&#x2F;&#x2F;rhnh.net&#x2F;2008&#x2F;04&#x2F;19&#x2F;testing-flash-now-with-rspec&quot;&gt;of us&lt;&#x2F;a&gt; Rails developers have probably come across when writing tests for flash messages being set with &lt;code&gt;flash.now&lt;&#x2F;code&gt;, &lt;a href=&quot;https:&#x2F;&#x2F;chuyeow.wtf&#x2F;2006&#x2F;09&#x2F;03&#x2F;some-functional-testing-gotchas-in-ruby-on-rails&#x2F;&quot;&gt;myself included&lt;&#x2F;a&gt;. Basically, you couldn&#x27;t test the contents of your &lt;code&gt;flash.now&lt;&#x2F;code&gt; because they were always being emptied before your test could get to them.&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;# In your controller:
flash.now[:notice] = &#x27;You gotta be kidding me!&#x27;
&lt;h1 id=&quot;in-your-test&quot;&gt;In your test:&lt;&#x2F;h1&gt;
&lt;p&gt;assert_equal &#x27;You gotta be kidding me!&#x27;, flash.now[:notice]&lt;&#x2F;p&gt;
&lt;h1 id=&quot;fails-because-flash-now-notice-is-nil&quot;&gt;FAILS because flash.now[:notice] is nil&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;&lt;a href=&quot;http:&#x2F;&#x2F;zargony.com&#x2F;&quot;&gt;Andreas Neuhaus&lt;&#x2F;a&gt; took a good look at how it works and figured out how to make testing &lt;code&gt;flash.now&lt;&#x2F;code&gt; work without resorting to &lt;code&gt;assert_select&lt;&#x2F;code&gt;s.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;code&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;74eed6290e63111d1aad2b181692a84f4f040aea&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;There isn&#x27;t much else of note so far but if you&#x27;d like to know every gritty detail, you&#x27;d probably want to peruse the &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commits&#x2F;master&quot;&gt;Rails commit logs&lt;&#x2F;a&gt;. As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series.&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #19 - change_table for migrations and more</title>
    <published>2008-05-04T20:18:54+00:00</published>
    <updated>2008-05-04T20:18:54+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/05/04/living-on-the-edge-of-rails-19-change_table-for-migrations-and-more/"/>
    <id>https://chuyeow.wtf/2008/05/04/living-on-the-edge-of-rails-19-change_table-for-migrations-and-more/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/05/04/living-on-the-edge-of-rails-19-change_table-for-migrations-and-more/">&lt;p&gt;This week’s report covers changes from 29 April 2008 to 4th May 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;change_table for ActiveRecord migrations&lt;&#x2F;h3&gt;
&lt;p&gt;Thanks to &lt;a href=&quot;http:&#x2F;&#x2F;zilkey.com&#x2F;&quot;&gt;Jeff Dean&lt;&#x2F;a&gt;, who also &lt;a href=&quot;http:&#x2F;&#x2F;zilkey.com&#x2F;2008&#x2F;4&#x2F;29&#x2F;new-rails-core-feature-proposal-super-sexy-migrations&quot;&gt;blogged about the new change_table feature in ActiveRecord migrations&lt;&#x2F;a&gt;, you can now change a table with a block like so:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;change_table :videos do |t|
  t.add_timestamps
  t.add_belongs_to :goat
  t.add_string :name, :email, :limit =&amp;gt; 20
  t.remove_column :name, :email # takes multiple arguments
  t.rename :new_name
  t.string :new_string_column # executes against the renamed table name
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Some key things to note:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;add_XXX&lt;&#x2F;code&gt; would add a new column for you, e.g. &lt;code&gt;add_string&lt;&#x2F;code&gt; would add a new string field.&lt;&#x2F;li&gt;
&lt;li&gt;Of course, add_timestamps would add the magic &lt;code&gt;created_at&lt;&#x2F;code&gt; and &lt;code&gt;updated_at&lt;&#x2F;code&gt; datetime fields.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;remove_column&lt;&#x2F;code&gt; now takes multiple arguments.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;rename&lt;&#x2F;code&gt; would rename the table.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Very nice, DRY enhancement, props to &lt;a href=&quot;http:&#x2F;&#x2F;zilkey.com&#x2F;&quot;&gt;Jeff Dean&lt;&#x2F;a&gt; once again.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;96980bd561d79824b6cb6efbcbecdcbf8785d452&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;96980bd561d79824b6cb6efbcbecdcbf8785d452&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveRecord::Base.create takes a block like ActiveRecord::Base.new&lt;&#x2F;h3&gt;
&lt;p&gt;Yup now you can also &lt;code&gt;create&lt;&#x2F;code&gt; ActiveRecord objects with a block argument just like you could for &lt;code&gt;ActiveRecord::Base.new&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;@person = Person.create(params[:person]) do |p|
  p.name = &#x27;Konata Izumi&#x27;
  p.age = 17
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Credit goes to &lt;a href=&quot;http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;11022-adam-meehan&quot;&gt;Adam Meehan&lt;&#x2F;a&gt; for this patch.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;dd120ede53eaf71dee76894998a81626b7a689fc&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;dd120ede53eaf71dee76894998a81626b7a689fc&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Bugfix: change_column should be able to use :null =&gt; true on a field that&lt;br &#x2F;&gt;
formerly had false&lt;&#x2F;h3&gt;
&lt;p&gt;You can now use &lt;code&gt;change_column&lt;&#x2F;code&gt; in your migrations to alter a column as nullable if it was previously &lt;code&gt;NOT NULL&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;This bugfix is courtesy of Nate Wiger.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;10ef65a3b054270ed3d458ec8eb7c2b9a3e638f7&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;10ef65a3b054270ed3d458ec8eb7c2b9a3e638f7&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series.&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the Edge (of Rails) in French</title>
    <published>2008-05-01T00:07:34+00:00</published>
    <updated>2008-05-01T00:07:34+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/05/01/living-on-the-edge-of-rails-in-french/"/>
    <id>https://chuyeow.wtf/2008/05/01/living-on-the-edge-of-rails-in-french/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/05/01/living-on-the-edge-of-rails-in-french/">&lt;p&gt;It looks like &lt;a href=&quot;http:&#x2F;&#x2F;blog.shingara.fr&#x2F;&quot;&gt;Cyril Mougel&lt;&#x2F;a&gt; has translated my 2 latest posts to French: &lt;a href=&quot;http:&#x2F;&#x2F;blog.shingara.fr&#x2F;articles&#x2F;2008&#x2F;04&#x2F;24&#x2F;vivre-avec-rails-edge-17&quot;&gt;LotE #17&lt;&#x2F;a&gt; and &lt;a href=&quot;http:&#x2F;&#x2F;blog.shingara.fr&#x2F;articles&#x2F;2008&#x2F;04&#x2F;29&#x2F;vivre-avec-rails-edge-18&quot;&gt;#18&lt;&#x2F;a&gt;. Thanks Cyril!&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #18</title>
    <published>2008-04-27T19:18:36+00:00</published>
    <updated>2008-04-27T19:18:36+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/04/27/living-on-the-edge-of-rails-18/"/>
    <id>https://chuyeow.wtf/2008/04/27/living-on-the-edge-of-rails-18/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/04/27/living-on-the-edge-of-rails-18/">&lt;p&gt;This week’s report covers changes from 21 Apr 2008 to 27 Apr 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;p&gt;Not much interesting to report this week - there were mostly a bunch of bugfixes and Ruby 1.8.7-compatibility &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commits&#x2F;master&quot;&gt;commits&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3&gt;Introduce ActiveResource::Base.timeout and rescuing from Timeout::Error in ActiveResource::Connection&lt;&#x2F;h3&gt;
&lt;p&gt;These are &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;105910429d5873dce677ef32eef5f705e0625d86&quot;&gt;2&lt;&#x2F;a&gt; &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;cf32baf915442ffe153ec0e4d8148f147776c30a&quot;&gt;changes&lt;&#x2F;a&gt; that I&#x27;d &lt;a href=&quot;https:&#x2F;&#x2F;chuyeow.wtf&#x2F;2008&#x2F;04&#x2F;22&#x2F;new-in-rails-activeresource-timeouts-and-why-it-matters&#x2F;&quot;&gt;talked about&lt;&#x2F;a&gt; earlier this week so I won&#x27;t repeat myself - take a read through &lt;a href=&quot;https:&#x2F;&#x2F;chuyeow.wtf&#x2F;2008&#x2F;04&#x2F;22&#x2F;new-in-rails-activeresource-timeouts-and-why-it-matters&#x2F;&quot;&gt;ActiveResource timeouts and why it matters&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3&gt;Smart integer datatype for the MySQL adapter in migrations&lt;&#x2F;h3&gt;
&lt;p&gt;The MySQL adapter in Rails now maps the &lt;code&gt;integer&lt;&#x2F;code&gt; column type in your migrations to either smallint, int, or bigint depending on the :limit option.&lt;&#x2F;p&gt;
&lt;p&gt;This means that a migration like this:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def self.up
  create_table :searches do |t|
    t.integer :foo, :limit =&gt; 2
  end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;will create your &lt;code&gt;foo&lt;&#x2F;code&gt; column as a &lt;code&gt;smallint(2)&lt;&#x2F;code&gt; MySQL datatype (instead of &lt;code&gt;int(2)&lt;&#x2F;code&gt; before). (More information &lt;a href=&quot;http:&#x2F;&#x2F;dev.mysql.com&#x2F;doc&#x2F;refman&#x2F;5.0&#x2F;en&#x2F;numeric-types.html&quot;&gt;MySQL numeric datatypes&lt;&#x2F;a&gt;.)&lt;&#x2F;p&gt;
&lt;p&gt;Credit goes to DHH for this patch.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;a37546517dad9f6d9a7de6e1dba4d960909d71e8&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;a37546517dad9f6d9a7de6e1dba4d960909d71e8&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series.&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #17</title>
    <published>2008-04-20T19:21:22+00:00</published>
    <updated>2008-04-20T19:21:22+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/04/20/living-on-the-edge-of-rails-17/"/>
    <id>https://chuyeow.wtf/2008/04/20/living-on-the-edge-of-rails-17/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/04/20/living-on-the-edge-of-rails-17/">&lt;p&gt;Not much going on this week on edge Rails. It does seem however that we do have a new Rails core member, &lt;a href=&quot;http:&#x2F;&#x2F;joshpeek.com&#x2F;&quot;&gt;Joshua Peek&lt;&#x2F;a&gt;. Also, the new &lt;a href=&quot;http:&#x2F;&#x2F;rails.lighthouseapp.com&#x2F;&quot;&gt;Rails&#x27; bug tracker&lt;&#x2F;a&gt; hosted on Lighthouse is ready for use, so be sure to submit your patches and bug reports there.&lt;&#x2F;p&gt;
&lt;p&gt;This week’s report covers changes from 14 Apr 2008 to 20 Apr 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;Conditional caches_page&lt;&#x2F;h3&gt;
&lt;p&gt;The &lt;code&gt;caches_page&lt;&#x2F;code&gt; now takes an &lt;code&gt;:if&lt;&#x2F;code&gt; option for specifying when a page can actually be cached via a Proc. You can now do this, for example:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;caches_page :index, :if =&amp;gt; Proc.new { |c| !c.request.format.json? }&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;That will only cache your index page if the requested format is not JSON.&lt;&#x2F;p&gt;
&lt;p&gt;Credit goes to &lt;a href=&quot;http:&#x2F;&#x2F;deaddeadgood.com&#x2F;&quot;&gt;Paul Horsfall&lt;&#x2F;a&gt; for this enhancement.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;14a40804a29a57ad05ca6bffbe1e5334089593a9&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;14a40804a29a57ad05ca6bffbe1e5334089593a9&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;New ActionView::TestCase for testing view helpers&lt;&#x2F;h3&gt;
&lt;p&gt;Remember how you can now use &lt;a href=&quot;https:&#x2F;&#x2F;chuyeow.wtf&#x2F;2007&#x2F;12&#x2F;27&#x2F;dry-in-your-functional-and-actionmailer-tests-rails-20-a-feature-a-day-7&#x2F;&quot;&gt;specialized TestCase classes for testing controllers and ActionMailer classes&lt;&#x2F;a&gt;? Now you can do the same with your Rails view helpers with the new ActionView::TestCase class.&lt;&#x2F;p&gt;
&lt;p&gt;Here&#x27;s a quick example:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;module PeopleHelper
  def title(text)
    content_tag(:h1, text)
  end
&lt;p&gt;def homepage_path
people_path
end
end&lt;&#x2F;p&gt;
&lt;p&gt;class PeopleHelperTest &amp;lt; ActionView::TestCase
def setup
ActionController::Routing::Routes.draw do |map|
map.people &#x27;people&#x27;, :controller =&amp;gt; &#x27;people&#x27;, :action =&amp;gt; &#x27;index&#x27;
map.connect &#x27;:controller&#x2F;:action&#x2F;:id&#x27;
end
end&lt;&#x2F;p&gt;
&lt;p&gt;def test_title
assert_equal &quot;&amp;lt;h1&amp;gt;Ruby on Rails&amp;lt;&#x2F;h1&amp;gt;&quot;, title(&quot;Ruby on Rails&quot;)
end&lt;&#x2F;p&gt;
&lt;p&gt;def test_homepage_path
assert_equal &quot;&#x2F;people&quot;, homepage_path
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Credit goes to Josh Peek for this sweet little enhancement.&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveSupport::Cache&#x27;s mem_cache_store accepts options&lt;&#x2F;h3&gt;
&lt;p&gt;Even though Memcache-client was added to ActiveSupport recently, it didn&#x27;t allow you to specify any configuration options beyond just the IP of the memcached server. Now you can pass along more configuration options like so:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;config.action_controller.fragment_cache_store = :mem_cache_store, &#x27;localhost&#x27;, { :compression =&amp;gt; true, :debug =&amp;gt; true, :namespace =&amp;gt; &#x27;foo&#x27; }&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This patch is courtesy of &lt;a href=&quot;http:&#x2F;&#x2F;blog.innerewut.de&#x2F;&quot;&gt;Jonathan Weiss&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;9e1d506a8cfedef2fdd605e4cbf4bf53651ad214&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;9e1d506a8cfedef2fdd605e4cbf4bf53651ad214&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series.&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #16 - Github edition</title>
    <published>2008-04-13T16:09:43+00:00</published>
    <updated>2008-04-13T16:09:43+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/04/13/living-on-the-edge-of-rails-16-github-edition/"/>
    <id>https://chuyeow.wtf/2008/04/13/living-on-the-edge-of-rails-16-github-edition/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/04/13/living-on-the-edge-of-rails-16-github-edition/">&lt;p&gt;A slight change this week since &lt;a href=&quot;http:&#x2F;&#x2F;weblog.rubyonrails.org&#x2F;2008&#x2F;4&#x2F;11&#x2F;rails-premieres-on-github&quot;&gt;Rails has moved to Git&lt;&#x2F;a&gt; - all changesets are now referenced to &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;tree&#x2F;master&quot;&gt;Github&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;This week’s report covers changes from 7 Apr 2008 to 13 Apr 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;A helpers proxy method for accessing helper methods from outside of views&lt;&#x2F;h3&gt;
&lt;p&gt;A &lt;code&gt;helpers&lt;&#x2F;code&gt; method has been introduced to ActionController - you can now access your helpers like so:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;ApplicationController.helpers.simple_format(text)&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Credit goes to 19 year old &lt;a href=&quot;http:&#x2F;&#x2F;joshpeek.com&#x2F;&quot;&gt;Josh Peek&lt;&#x2F;a&gt;, one of the more prolific Rails contributors (and most likely to join Pratik in Rails Core imo).&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;917423d664038d6791738a73ad1446437dbb71df&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;917423d664038d6791738a73ad1446437dbb71df&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;json_escape for escaping HTML entities in JSON strings&lt;&#x2F;h3&gt;
&lt;p&gt;A &lt;code&gt;json_escape&lt;&#x2F;code&gt; (aliased as &lt;code&gt;j&lt;&#x2F;code&gt;, similar to how &lt;code&gt;html_escape&lt;&#x2F;code&gt; is aliased as &lt;code&gt;h&lt;&#x2F;code&gt;) has been introduced by Rick Olson for escaping HTML entities in JSON strings. This is useful if you find yourself emitting JSON strings in HTML pages (e.g. for documenting a JSON API):&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;json_escape(&quot;is a &amp;gt; 0 &amp;amp; a &amp;lt; 10?&quot;)
# =&gt; is a \u003E 0 \u0026 a \u003C 10?&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Of course, since &lt;code&gt;json_escape&lt;&#x2F;code&gt; is aliased as &lt;code&gt;j&lt;&#x2F;code&gt;, you can do this in your ERB templates:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&lt;%=j @person.to_json %&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;0ff7a2d89fc95dcb0a32ed92aab7156b0778a7ea&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;0ff7a2d89fc95dcb0a32ed92aab7156b0778a7ea&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Automatically parse posted JSON content for Mime::JSON requests&lt;&#x2F;h3&gt;
&lt;p&gt;Rails will now accept POSTed JSON content! For example, you can now send a POST to &quot;&#x2F;posts&quot; of your Post resource like this:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;POST &#x2F;posts
{&quot;post&quot;: {&quot;title&quot;: &quot;Breaking News&quot;}}&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;And your &lt;code&gt;create&lt;&#x2F;code&gt; action will automatically parse the POSTed JSON into the request &lt;code&gt;params&lt;&#x2F;code&gt; so that this code below just works:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def create
  @post = Post.create params[:post]
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Credit goes to Rick Olson.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;4d594cffcfc93b37fad4e423ec8593299e50133c&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;4d594cffcfc93b37fad4e423ec8593299e50133c&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;schema_migrations table replaces the schema_info table, allowing for interleaved migrations&lt;&#x2F;h3&gt;
&lt;p&gt;A new schema_migrations table for storing which migrations have been run has been introduced, and this replaces the existing schema_info table (which simply keeps track of the last applied schema version). This change makes it possible to add migrations (for example, after you&#x27;ve merged from someone&#x27;s branch) - when you migrate your database via rake db:migrate, those never-applied &quot;interleaved&quot; migrations will be run. Similarly, when migrating down schema versions, never-applied &quot;interleaved&quot; will be skipped.&lt;&#x2F;p&gt;
&lt;p&gt;See &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;ticket&#x2F;11493&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;ticket&#x2F;11493&lt;&#x2F;a&gt; for more information.&lt;&#x2F;p&gt;
&lt;p&gt;This useful patch is the brainchild of &lt;a href=&quot;http:&#x2F;&#x2F;bunster.org&#x2F;&quot;&gt;Jordi Bunster&lt;&#x2F;a&gt; (&lt;a href=&quot;http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;12130-jordi-bunster&quot;&gt;WWR profile&lt;&#x2F;a&gt;). I&#x27;m sure many Rails developers who branch extensively will thank Jordi for this excellent patch!&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;8a5a9dcbf64843f064b6e8a0b9c6eea8f0b8536e&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;8a5a9dcbf64843f064b6e8a0b9c6eea8f0b8536e&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;gems:unpack:dependencies Rake task&lt;&#x2F;h3&gt;
&lt;p&gt;Remember how you can now run the &lt;code&gt;gems:unpack&lt;&#x2F;code&gt; Rake task to unpack a gem into your &lt;code&gt;vendor&#x2F;gems&#x2F;&lt;&#x2F;code&gt; directory (this was &lt;a href=&quot;https:&#x2F;&#x2F;chuyeow.wtf&#x2F;2008&#x2F;04&#x2F;05&#x2F;living-on-the-edge-of-rails-14-the-extreme-edition-extremely-late&#x2F;&quot;&gt;mentioned in an earlier Living on the Edge&lt;&#x2F;a&gt;)?&lt;&#x2F;p&gt;
&lt;p&gt;David Dollar (&lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;ddollar&quot;&gt;Github profile&lt;&#x2F;a&gt;) has firmed up that patch quite a bit by adding the &lt;code&gt;gems:unpack:dependencies&lt;&#x2F;code&gt; Rake task that unpacks the dependencies of the gems as well. So running:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;gems:unpack:dependencies GEM=activecouch&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;would unpack the full Rubygem dependency tree of gems that the &lt;a href=&quot;http:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;activecouch&#x2F;&quot;&gt;activecouch&lt;&#x2F;a&gt; gem depends upon.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;4364c361b599f99bc2345ce4eb2d145b07ed8a0f&quot;&gt;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;commit&#x2F;4364c361b599f99bc2345ce4eb2d145b07ed8a0f&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series! Now go out there and start &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;rails&#x2F;rails&#x2F;tree&#x2F;master&quot;&gt;forking Rails&lt;&#x2F;a&gt;!&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #15 - the early edition</title>
    <published>2008-04-06T15:57:01+00:00</published>
    <updated>2008-04-06T15:57:01+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/04/06/living-on-the-edge-of-rails-15-the-early-edition/"/>
    <id>https://chuyeow.wtf/2008/04/06/living-on-the-edge-of-rails-15-the-early-edition/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/04/06/living-on-the-edge-of-rails-15-the-early-edition/">&lt;p&gt;I&#x27;m gonna post up the Living on the Edge a little earlier this week because I&#x27;ve found I just can&#x27;t keep up (when things get busy) with 2 separate sets of notes for the &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; and another for my own blog posts.&lt;&#x2F;p&gt;
&lt;p&gt;From this week onwards, I&#x27;ll be following &lt;a href=&quot;http:&#x2F;&#x2F;m.onkey.org&quot;&gt;Pratik&lt;&#x2F;a&gt;&#x27;s suggestion to post about changes as they happen instead of after an entire week so expect a slight change in the format of Living on the edge for next week!&lt;&#x2F;p&gt;
&lt;p&gt;This week’s report covers changes from 31 Mar 2008 to 6 Apr 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;Rails.env, Rails.logger, Rails.cache, Rails.root&lt;&#x2F;h3&gt;
&lt;p&gt;This has been a long time coming: You can now use &lt;code&gt;Rails.env&lt;&#x2F;code&gt; instead of &lt;code&gt;RAILS_ENV&lt;&#x2F;code&gt;, &lt;code&gt;Rails.root&lt;&#x2F;code&gt; instead of &lt;code&gt;RAILS_ROOT&lt;&#x2F;code&gt;, &lt;code&gt;Rails.logger&lt;&#x2F;code&gt; instead of &lt;code&gt;RAILS_DEFAULT_LOGGER&lt;&#x2F;code&gt;, and &lt;code&gt;Rails.cache&lt;&#x2F;code&gt; instead of &lt;code&gt;RAILS_CACHE&lt;&#x2F;code&gt;. Not having to use constants is nice because it always felt a bit dirty to have so many hard-coded constants in the Rails namespace.&lt;&#x2F;p&gt;
&lt;p&gt;Credit goes to &lt;a href=&quot;http:&#x2F;&#x2F;m.onkey.org&#x2F;&quot;&gt;Pratik Naik&lt;&#x2F;a&gt;, the newest Rails core team member for this cleanup.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9180&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9180&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Render :partial now works with a collection of heterogeneous elements&lt;&#x2F;h3&gt;
&lt;p&gt;You can now use &lt;code&gt;render :partial&lt;&#x2F;code&gt; to render a collection of different elements and Rails will figure out which partial template to use. For example:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;render :partial =&gt; [ monkey, donkey, dramatic_chipmunk ]&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;will render the monkey with the &#x27;monkeys&#x2F;_monkey.html.erb&#x27; partial, donkey with the &#x27;donkeys&#x2F;_donkey.html.erb&#x27; partial, and last but definitely not lest, dramatic_gopher with the &#x27;dramatic_chipmunks&#x2F;_dramatic_chipmunk.html.erb&#x27; partial&lt;&#x2F;p&gt;
&lt;p&gt;This is especially useful if when using &lt;acronym title=&quot;Single Table Inheritance&quot;&gt;STI&lt;&#x2F;acronym&gt;, where your ActiveRecord model would return objects of different types. The collection &lt;code&gt;[ monkey, donkey, dramatic_chipmunk ]&lt;&#x2F;code&gt; could very well be something returned from your &lt;code&gt;Animal&lt;&#x2F;code&gt; model that has subclasses of &lt;code&gt;Monkey&lt;&#x2F;code&gt;, &lt;code&gt;Donkey&lt;&#x2F;code&gt; and &lt;code&gt;DramaticChipmunk&lt;&#x2F;code&gt; via STI.&lt;&#x2F;p&gt;
&lt;p&gt;Credit: &lt;a href=&quot;http:&#x2F;&#x2F;www.continuousthinking.com&#x2F;&quot;&gt;Zach Dennis&lt;&#x2F;a&gt; of &lt;a href=&quot;http:&#x2F;&#x2F;www.continuousthinking.com&#x2F;tags&#x2F;arext&quot;&gt;ar-extensions&lt;&#x2F;a&gt; fame.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9177&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9177&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveModel work revived&lt;&#x2F;h3&gt;
&lt;p&gt;It seems like work on ActiveModel (think unified ActiveRecord and ActiveResource behaviors) has been revived, if the latest commits (&lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9171&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9171&lt;&#x2F;a&gt; and &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9173&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9173&lt;&#x2F;a&gt;) by David (DHH) is anything to go by.&lt;&#x2F;p&gt;
&lt;h3&gt;Bugfix: Assigning an invalid has_one association now causes #save to fail on parent&lt;&#x2F;h3&gt;
&lt;p&gt;You could do this before:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;firm = Firm.find(:first)
firm.account = Account.new # Associate INVALID account
firm.save # This doesn&#x27;t fail&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Now that&#x27;s fixed thanks to &lt;a href=&quot;http:&#x2F;&#x2F;m.onkey.org&#x2F;&quot;&gt;Pratik Naik&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9232&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9232&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As usual, any feedback is respectfully appreciated!&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #14 - the extreme edition. Extremely late.</title>
    <published>2008-04-05T00:04:06+00:00</published>
    <updated>2008-04-05T00:04:06+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/04/05/living-on-the-edge-of-rails-14-the-extreme-edition-extremely-late/"/>
    <id>https://chuyeow.wtf/2008/04/05/living-on-the-edge-of-rails-14-the-extreme-edition-extremely-late/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/04/05/living-on-the-edge-of-rails-14-the-extreme-edition-extremely-late/">&lt;p&gt;This week’s report covers changes from 24 Mar 2008 to 30 Mar 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;p&gt;There&#x27;re lots of big exciting changes this week on edge. Smells like 2.1 soon!&lt;&#x2F;p&gt;
&lt;h3&gt;has_finder gem merged into Rails&lt;&#x2F;h3&gt;
&lt;p&gt;Ryan Daigle has &lt;a href=&quot;http:&#x2F;&#x2F;ryandaigle.com&#x2F;articles&#x2F;2008&#x2F;3&#x2F;24&#x2F;what-s-new-in-edge-rails-has-finder-functionality&quot;&gt;the scoop on the new has_finder-like functionality in Rails&lt;&#x2F;a&gt; so head on over (I won&#x27;t repeat it here in the interests of &lt;acronym title=&quot;Don&#x27;t Repeat Yourself&quot;&gt;DRY&lt;&#x2F;acronym&gt;).&lt;&#x2F;p&gt;
&lt;p&gt;Credit goes to &lt;a href=&quot;http:&#x2F;&#x2F;pivots.pivotallabs.com&#x2F;users&#x2F;nick&#x2F;blog&#x2F;articles&#x2F;284-hasfinder-it-s-now-easier-than-ever-to-create-complex-re-usable-sql-queries&quot;&gt;Nick Kallen&lt;&#x2F;a&gt; for coming up with the has_finder gem.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9084&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9084&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveRecord: Unsaved attribute changes are now tracked&lt;&#x2F;h3&gt;
&lt;p&gt;You can now ask an ActiveRecord model whether its attributes have been changed (and is unsaved) using the &lt;code&gt;{attr_name}_changed?&lt;&#x2F;code&gt; (magic) method. The &lt;code&gt;{attr_name}_was&lt;&#x2F;code&gt; method will return the original value of the attribute, and the &lt;code&gt;{attr_name}_change&lt;&#x2F;code&gt; method will return an array with 2 members, the 1st being the original value, the 2nd being the changed (and unsaved) value.&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;# Change person&#x27;s name.
person.name = &#x27;Jason Seifer&#x27;
person.changed?       # =&gt; true
person.name_changed?  # =&gt; true
person.name_was       # =&gt; &#x27;jseifer&#x27;
person.name_change    # =&gt; [&#x27;jseifer&#x27;, &#x27;Jason Seifer&#x27;]
person.name = &#x27;Ceiling Cat&#x27;
person.name_change    # =&gt; [&#x27;jseifer&#x27;, &#x27;Ceiling Cat&#x27;]&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Credit goes to Rails core team member Jeremy Kemper (bitsweat) for this patch (which originated from Jeremy&#x27;s very own &lt;a href=&quot;http:&#x2F;&#x2F;code.bitsweat.net&#x2F;svn&#x2F;dirty&quot;&gt;Dirty plugin&lt;&#x2F;a&gt;).&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9127&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9127&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveRecord#Base.all&#x2F;first&#x2F;last&lt;&#x2F;h3&gt;
&lt;p&gt;Now you can do:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;Post.all.each { |post| # something }
Post.first
Post.last&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Kinda like how some other ORMs do (like DataMapper).&lt;&#x2F;p&gt;
&lt;p&gt;Credit: &lt;a href=&quot;http:&#x2F;&#x2F;www.thechrisoshow.com&#x2F;&quot;&gt;thechrisoshow&lt;&#x2F;a&gt; and again, Nick Kallen for has_finder.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9085&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9085&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Timestamped Migrations&lt;&#x2F;h3&gt;
&lt;p&gt;This is more useful than it sounds: migrations are now timestamped instead of using incremental numbers in your db&#x2F;migrate folder. This eliminates the problem of migrations having the same version number when working on a multi-developer Rails app.&lt;&#x2F;p&gt;
&lt;p&gt;Two new Rake tasks, rake &lt;code&gt;db:migrate:up&#x2F;down&lt;&#x2F;code&gt;, have been added to allow running of the &lt;code&gt;up&lt;&#x2F;code&gt; and &lt;code&gt;down&lt;&#x2F;code&gt; methods of individual migrations.&lt;&#x2F;p&gt;
&lt;p&gt;Credit goes to John Barnette, the guy who gave you &lt;a href=&quot;http:&#x2F;&#x2F;ryandaigle.com&#x2F;articles&#x2F;2007&#x2F;10&#x2F;26&#x2F;what-s-new-in-edge-rails-fixtures-just-got-a-whole-lot-easier&quot;&gt;foxy fixtures&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset:&lt;a href=&quot; http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9122&quot;&gt; http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9122&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;New config.gem option for specifying which gems are required by the application + rake tasks for installing and freezing gems&lt;&#x2F;h3&gt;
&lt;p&gt;Specify which gems are required by your Rails app in your Rails &lt;code&gt;environment.rb&lt;&#x2F;code&gt;! &quot;Vendor everything&quot; supported right in Rails :). An example:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;Rails::Initializer.run do |config| 
  config.gems &#x27;chronic&#x27;
  config.gems &quot;hpricot&quot;, :version =&gt; &#x27;0.6&#x27;, :source =&gt; &quot;http:&#x2F;&#x2F;code.whytheluckystiff.net&quot;
  config.gems &quot;aws-s3&quot;, :lib =&gt; &quot;aws&#x2F;s3&quot;
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;There are also new Rake tasks:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;# List required gems. 
rake gems 
&lt;h1 id=&quot;install-all-required-gems&quot;&gt;Install all required gems:&lt;&#x2F;h1&gt;
&lt;p&gt;rake gems:install&lt;&#x2F;p&gt;
&lt;h1 id=&quot;unpack-specified-gem-to-vendor-gems-gem-name-x-x-x&quot;&gt;Unpack specified gem to vendor&#x2F;gems&#x2F;gem_name-x.x.x&lt;&#x2F;h1&gt;
&lt;p&gt;rake gems:unpack GEM=chronic&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Credit goes to the prolific &lt;a href=&quot;http:&#x2F;&#x2F;techno-weenie.net&#x2F;&quot;&gt;Rick Olson&lt;&#x2F;a&gt; for this gem of a patch.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9140&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9140&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveResource #clone&lt;&#x2F;h3&gt;
&lt;p&gt;You can now clone an existing resource:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;gregg = Person.find(1)
borg = gregg.clone&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This doesn&#x27;t clone child ActiveResource members though, just the straight up attributes of resource.&lt;&#x2F;p&gt;
&lt;p&gt;Contribors: &lt;a href=&quot;http:&#x2F;&#x2F;ryandaigle.com&#x2F;&quot;&gt;Ryan Daigle&lt;&#x2F;a&gt; and &lt;a href=&quot;http:&#x2F;&#x2F;www.thechrisoshow.com&#x2F;&quot;&gt;thechrisoshow&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9121&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9121&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Big documentation patch&lt;&#x2F;h3&gt;
&lt;p&gt;A big doc patch consisting of all the efforts going on in the &lt;a href=&quot;http:&#x2F;&#x2F;github.com&#x2F;lifo&#x2F;doc-rails&#x2F;&quot;&gt;doc-rails repository on Github&lt;&#x2F;a&gt; has been committed. Check out &lt;a href=&quot;http:&#x2F;&#x2F;groups.google.com&#x2F;group&#x2F;rubyonrails-core&#x2F;browse_thread&#x2F;thread&#x2F;92f822141df3c217&#x2F;71e7460d41bdfd89&quot;&gt;Pratik&#x27;s post&lt;&#x2F;a&gt; for more info on what doc-rails is. Though with Rails moving to Git soon, doc-rails may no longer be necessary!&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9093&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9093&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #13 - Git script&#x2F;plugin install, has_one :through</title>
    <published>2008-03-27T23:46:34+00:00</published>
    <updated>2008-03-27T23:46:34+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/03/27/living-on-the-edge-of-rails-13-git-scriptplugin-install-has_one-through/"/>
    <id>https://chuyeow.wtf/2008/03/27/living-on-the-edge-of-rails-13-git-scriptplugin-install-has_one-through/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/03/27/living-on-the-edge-of-rails-13-git-scriptplugin-install-has_one-through/">&lt;p&gt;It&#x27;s time again for some edge Rails love. If you haven&#x27;t listened to it yet, be sure to check out &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;2008&#x2F;3&#x2F;26&#x2F;rails-envy-podcast-episode-024-03-26-2008&quot;&gt;this week&#x27;s Rails Envy podcast&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;This week’s report covers changes from 17 Mar 2008 to 23 Mar 2008 (the day the &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;2008&#x2F;3&#x2F;26&#x2F;rails-envy-podcast-episode-024-03-26-2008&quot;&gt;corresponding Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;script&#x2F;plugin install works for Git repositories&lt;&#x2F;h3&gt;
&lt;p&gt;Yup you can now install plugins from &lt;a href=&quot;http:&#x2F;&#x2F;git.or.cz&#x2F;&quot;&gt;Git&lt;&#x2F;a&gt; repositories simply by running:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;script&#x2F;plugin install git:&#x2F;&#x2F;github.com&#x2F;foo&#x2F;kung_fu&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;p&gt;What this really does is to clone a git repository (sans the entire git history by passing the &lt;code&gt;—depth 1&lt;&#x2F;code&gt; option) into your plugins directory. If you&#x27;re looking for a Piston-like way to manage external Git repositories though, you&#x27;d still be better off with the development version of &lt;a href=&quot;http:&#x2F;&#x2F;piston.rubyforge.org&#x2F;&quot;&gt;Piston&lt;&#x2F;a&gt; (François Beausoleil, is &lt;a href=&quot;http:&#x2F;&#x2F;blog.teksol.info&#x2F;tags&#x2F;piston&quot;&gt;posting frequently on his progress with adding Git support&lt;&#x2F;a&gt;).&lt;&#x2F;p&gt;
&lt;p&gt;Credit goes to &lt;a href=&quot;http:&#x2F;&#x2F;6brand.com&#x2F;git-svn-externals-rails-plugins&quot;&gt;Jack Danger&lt;&#x2F;a&gt;, a long-time Rails contributor for this patch.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9049&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9049&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;has_one :through&lt;&#x2F;h3&gt;
&lt;p&gt;It&#x27;s been a long time coming - now you can do &lt;code&gt;has_one :through&lt;&#x2F;code&gt; (like &lt;code&gt;has_many :through&lt;&#x2F;code&gt;) for your join models. &lt;a href=&quot;http:&#x2F;&#x2F;ryandaigle.com&#x2F;&quot;&gt;Ryan Daigle&lt;&#x2F;a&gt; has &lt;a href=&quot;http:&#x2F;&#x2F;ryandaigle.com&#x2F;articles&#x2F;2008&#x2F;3&#x2F;24&#x2F;what-s-new-in-edge-rails-has-one-through&quot;&gt;example code&lt;&#x2F;a&gt; on how to use it if you&#x27;re curious (though really, it&#x27;s just like has_many).&lt;&#x2F;p&gt;
&lt;p&gt;Credit goes to the &lt;a href=&quot;http:&#x2F;&#x2F;artofmission.com&#x2F;&quot;&gt;Art of Mission&lt;&#x2F;a&gt; guys and &lt;a href=&quot;http:&#x2F;&#x2F;www.thechrisoshow.com&#x2F; http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;9008-chris-o-sullivan&quot;&gt;Chris O&#x27;Sullivan&lt;&#x2F;a&gt; for pulling it all together.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9067&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9067&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;rake tasks time:zones:all, time:zones:us and time:zones:local&lt;&#x2F;h3&gt;
&lt;p&gt;Some timezone-related rake tasks have been added to list the names of time zones recognized by the &lt;code&gt;TimeZone&lt;&#x2F;code&gt; class for the &lt;code&gt;config.time_zone&lt;&#x2F;code&gt; option you can put in your &lt;code&gt;environment.rb&lt;&#x2F;code&gt;. For example&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;rake time:zones:local&lt;&#x2F;code&gt;&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code&gt;* UTC +08:00 *
Beijing
Chongqing
Hong Kong
Irkutsk
Kuala Lumpur
Perth
Singapore
Taipei
Ulaan Bataar
Urumqi&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Credit: Geoff Buesing (core team member)&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9074&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9074&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;#number_to_currency helper now supports a :format option&lt;&#x2F;h3&gt;
&lt;p&gt;Now you can do something like:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;number_to_currency(123.50, :unit =&gt; &quot;&amp;pound;&quot;, :format =&gt; &quot;%n %u&quot;) 
# =&gt; 123.50 &amp;pound;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Instead of being stuck with the &lt;code&gt;{currency_code} {amount}&lt;&#x2F;code&gt; format which doesn&#x27;t work in some locales (such as &quot;42 pounds&quot;).&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9052&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9052&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #12</title>
    <published>2008-03-20T20:19:18+00:00</published>
    <updated>2008-03-20T20:19:18+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/03/20/living-on-the-edge-of-rails-12/"/>
    <id>https://chuyeow.wtf/2008/03/20/living-on-the-edge-of-rails-12/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/03/20/living-on-the-edge-of-rails-12/">&lt;p&gt;This week’s report covers changes from 10 Mar 2008 to 16 Mar 2008 (the day the &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;2008&#x2F;3&#x2F;19&#x2F;rails-envy-podcast-episode-023-03-19-2008&quot;&gt;corresponding Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;Custom JavaScript and stylesheet symbols&lt;&#x2F;h3&gt;
&lt;p&gt;Remember how you can do something like:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;javascript_include_tag :defaults&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;and Rails would load all the Prototype JavaScript files and your application.js?&lt;&#x2F;p&gt;
&lt;p&gt;You can now register your own custom expansion symbol too:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;# In a Rails initializer.
ActionView::Helpers::AssetTagHelper.register_javascript_expansion :yui =&gt; [&#x27;yahoo&#x27;, &#x27;autocomplete&#x27;, &#x27;calendar&#x27;]
&lt;h1 id=&quot;in-your-view&quot;&gt;In your view.&lt;&#x2F;h1&gt;
&lt;p&gt;javascript_include_tag :yui&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;&#x2F;p&gt;
&lt;p&gt;would result in:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;html&quot;&gt;&amp;lt;script type=&quot;text&#x2F;javascript&quot; src=&quot;&#x2F;javascripts&#x2F;yahoo.js&quot;&amp;gt;&amp;lt;&#x2F;script&amp;gt;
&amp;lt;script type=&quot;text&#x2F;javascript&quot; src=&quot;&#x2F;javascripts&#x2F;autocomplete.js&quot;&amp;gt;&amp;lt;&#x2F;script&amp;gt;
&amp;lt;script type=&quot;text&#x2F;javascript&quot; src=&quot;&#x2F;javascripts&#x2F;calendar.js&quot;&amp;gt;&amp;lt;&#x2F;script&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;You can do the same with the &lt;cpde&gt;stylesheet_link_tag&lt;&#x2F;cpde&gt; by registering a custom expansion symbol via &lt;code&gt;register_stylesheet_expansion&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;This is useful for anyone but in particular plugin developers who have a multiple asset files would appreciate being able to tell users to include JavaScript or stylesheets using a single symbol.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Warning&lt;&#x2F;strong&gt;: This patch currently breaks the default symbols like &lt;code&gt;:all&lt;&#x2F;code&gt; (&lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;ticket&#x2F;10350&quot;&gt;check out the ticket&lt;&#x2F;a&gt; for more info).&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9016&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9016&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Sexy default timestamps in migrations&lt;&#x2F;h3&gt;
&lt;p&gt;Remember how you can say &lt;code&gt;timestamps&lt;&#x2F;code&gt; in a migration and Rails will create the &#x27;created_at&#x27; and &#x27;updated_at&#x27; columns for you? You can now also do &lt;code&gt;add_timestamps :table_name&lt;&#x2F;code&gt; and &lt;code&gt;remove_timestamps :table_name&lt;&#x2F;code&gt; in your migrations if you decide to add these columns later to a table:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def self.up
  add_timestamps :posts
end
&lt;p&gt;def self.down
remove_timestamps :posts
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9014&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9014&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveRecord::Base#find(:last)&lt;&#x2F;h3&gt;
&lt;p&gt;Just like &lt;code&gt;Comment.find(:first)&lt;&#x2F;code&gt;, you can now do something like &lt;code&gt;Comment.find(:last)&lt;&#x2F;code&gt;. There&#x27;s some controversy over whether this is bloat, but &lt;acronym title=&quot;David Heinemeier Hansson&quot;&gt;DHH&lt;&#x2F;acronym&gt; makes a good case for it with this example:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class Person
  has_many :comments, :order =&amp;gt; &#x27;created_at&#x27;
end
&lt;p&gt;@some_person.comments.find(:last) # =&amp;gt; Returns the most recent comment.&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9012&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9012&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Database rake tasks fixes&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;rake db:create&lt;&#x2F;code&gt; used to ignore the &#x27;charset&#x27; and &#x27;collation&#x27; options in your database.yml configuration file. This has been fixed so that your created databases now respect those options.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;rake db:drop&lt;&#x2F;code&gt; and &lt;code&gt;rake db:migrate:reset&lt;&#x2F;code&gt; also no longer crash with an unhelpful exception if the database has already been dropped, and instead shows a proper error message.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9004&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9004&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Rails&#x27; logger now creates the log directory if it doesn&#x27;t exist&lt;&#x2F;h3&gt;
&lt;p&gt;This is a blessing to those of us who use version control systems that don&#x27;t support empty directories (like Git). Rails&#x27; default logger (the BufferedLogger), now creates a log&#x2F; directory if it doesn&#x27;t already exist. This should save you the step of creating&#x2F;symlinking a log&#x2F; directory (or symlinking) on deploy.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9013&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9013&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;String#squish is faster&lt;&#x2F;h3&gt;
&lt;p&gt;A faster implementation of the &lt;code&gt;String#squish&lt;&#x2F;code&gt; (and &lt;code&gt;String#squish!&lt;&#x2F;code&gt;) core extension has been committed.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9015&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9015&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;The #excerpt TextHelper no longer includes 1 character too many&lt;&#x2F;h3&gt;
&lt;p&gt;Turns out that the &lt;code&gt;#excerpt&lt;&#x2F;code&gt; helper method was consistently including an extra character. This has been fixed.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9030&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;9030&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As usual, let me know of any inaccuracies or any suggestions you may have in the comments!&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #11</title>
    <published>2008-03-12T19:39:17+00:00</published>
    <updated>2008-03-12T19:39:17+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/03/12/living-on-the-edge-of-rails-11/"/>
    <id>https://chuyeow.wtf/2008/03/12/living-on-the-edge-of-rails-11/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/03/12/living-on-the-edge-of-rails-11/">&lt;p&gt;This week’s report covers changes from 3 Mar 2008 to 9 Mar 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;Improve performance on :include&#x2F;:conditions&#x2F;:limit queries by selectively joining in the pre-query&lt;&#x2F;h3&gt;
&lt;p&gt;This is another ActiveRecord performance boost related to the pre-loading any eager-loaded &lt;code&gt;:includes&lt;&#x2F;code&gt; &lt;a href=&quot;https:&#x2F;&#x2F;chuyeow.wtf&#x2F;2008&#x2F;01&#x2F;30&#x2F;living-on-the-edge-of-rails-5-better-eager-loading-and-more&#x2F;&quot;&gt;mentioned previously&lt;&#x2F;a&gt;. Basically what this patch does is to only join referenced tables when needed. It does this by checking the &lt;code&gt;:conditions&lt;&#x2F;code&gt; and &lt;code&gt;:limit&lt;&#x2F;code&gt; options to determine whether a table should be joined or can be left out and pre-loaded instead. You can find out more in tickets &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;ticket&#x2F;9560&quot;&gt;#9560&lt;&#x2F;a&gt; and &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;ticket&#x2F;9497&quot;&gt;#9497&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Credit goes to &lt;a href=&quot;http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;8164-gabe-da-silveira&quot;&gt; Gabe da Silveira&lt;&#x2F;a&gt; (dasil003 on Trac) for this awesome performance patch.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8977&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8977&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Better error message for type errors when parsing request parameters&lt;&#x2F;h3&gt;
&lt;p&gt;Now when you pass an incorrectly formed request (e.g. GET, POST) parameter to your controller, it will raise an exception that includes a friendlier error message that indicates exactly what you passed to it. This is helpful when trying to debug whether you constructed your form correctly.&lt;&#x2F;p&gt;
&lt;p&gt;Contributors: &lt;a href=&quot;http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;5519-chad-humphries&quot;&gt;Chad Humphries&lt;&#x2F;a&gt; and matt.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8986&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8986&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Make MimeResponds::Responder#any work without explicit types.&lt;&#x2F;h3&gt;
&lt;p&gt;Here&#x27;s something I didn&#x27;t know: you can actually use &lt;code&gt;any&lt;&#x2F;code&gt; in your &lt;code&gt;respond_to&lt;&#x2F;code&gt; blocks as a catch-all response. E.g.&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;respond_to do |format|
  format.html do
    redirect_to :action =&amp;gt; &#x27;login&#x27;
  end
  format.any(:js, :xml) do
    request_http_basic_authentication &#x27;Web Password&#x27;
  end
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Contrary to its name, using &#x27;any&#x27; actually requires you to pass a list of types to respond to. This has been enhanced now so that if you don&#x27;t pass any arguments, it&#x27;ll function as a real catch-all.&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;respond_to do |format|
  format.any do
    request_http_basic_authentication &#x27;Web Password&#x27;
  end
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Credit goes to &lt;a href=&quot;http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;3231-joshua-wehner&quot;&gt;Joshua Wehner&lt;&#x2F;a&gt; for this patch.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8987&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8987&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Add readonly option to has_many :through associations&lt;&#x2F;h3&gt;
&lt;p&gt;Turns out the &lt;code&gt;:readonly&lt;&#x2F;code&gt; option for associations &lt;a href=&quot;https:&#x2F;&#x2F;chuyeow.wtf&#x2F;2008&#x2F;02&#x2F;19&#x2F;living-on-the-edge-of-rails-8-the-code-optimization-edition&#x2F;&quot;&gt;mentioned earlier&lt;&#x2F;a&gt; was left out for &lt;code&gt;has_many :through&lt;&#x2F;code&gt; associations. This oversight has been fixed.&lt;&#x2F;p&gt;
&lt;p&gt;Thanks to &lt;a href=&quot;http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;9147-emilio-tagua&quot;&gt;Emilio Tagua&lt;&#x2F;a&gt; for this bugfix.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8989&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8989&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As usual, let me know of any inaccuracies or any suggestions you may have in the comments!&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #10</title>
    <published>2008-03-05T20:01:32+00:00</published>
    <updated>2008-03-05T20:01:32+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/03/05/living-on-the-edge-of-rails-10/"/>
    <id>https://chuyeow.wtf/2008/03/05/living-on-the-edge-of-rails-10/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/03/05/living-on-the-edge-of-rails-10/">&lt;p&gt;Another awfully sleepy week on Rails edge. Though by the time I had sent over the notes to Gregg Pollack and Jason Seifer of the awesome &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt;, there has been some nice changes (that I&#x27;ll be mentioning next week, but there&#x27;s absolutely nothing stopping you from &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;timeline?changeset=on&quot;&gt;checking those out yourself&lt;&#x2F;a&gt;).&lt;&#x2F;p&gt;
&lt;p&gt;In other interesting news, &lt;a href=&quot;http:&#x2F;&#x2F;m.onkey.org&#x2F;&quot;&gt;Pratik Naik&lt;&#x2F;a&gt; (lifofifo), a long-time Rails contributor has been given commit rights to Rails. Congrats Pratik, well-deserved and it has been long overdue in my opinion! Pratik keeps an interesting blog at &lt;a href=&quot;http:&#x2F;&#x2F;m.onkey.org&#x2F;&quot;&gt;http:&#x2F;&#x2F;m.onkey.org&#x2F;&lt;&#x2F;a&gt; (where he&#x27;s not afraid to say &quot;fuck&quot; in his posts &lt;em&gt;and&lt;&#x2F;em&gt; his code) and hangs out an awful lot on &lt;a href=&quot;irc:&#x2F;&#x2F;irc.freenode.net&#x2F;rubyonrails&quot;&gt;#rubyonrails&lt;&#x2F;a&gt; and &lt;a href=&quot;irc:&#x2F;&#x2F;irc.freenode.net&#x2F;rails-contrib&quot;&gt;#rails-contrib&lt;&#x2F;a&gt; on IRC.&lt;&#x2F;p&gt;
&lt;p&gt;As a sidenote, &lt;a href=&quot;http:&#x2F;&#x2F;weblog.jamisbuck.org&#x2F;2008&#x2F;2&#x2F;28&#x2F;capistrano-2-2-0&quot;&gt;Capistrano 2.2.0 was released&lt;&#x2F;a&gt; by &lt;a href=&quot;http:&#x2F;&#x2F;weblog.jamisbuck.org&#x2F;&quot;&gt;Jamis&lt;&#x2F;a&gt; last week.&lt;&#x2F;p&gt;
&lt;p&gt;This week’s report covers changes from 25 Feb 2008 to 2 Mar 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;Time#end_of_XXX methods&lt;&#x2F;h3&gt;
&lt;p&gt;A bunch of Time core extension methods have been added. These are: &lt;code&gt;Time#end_of_day&lt;&#x2F;code&gt;, &lt;code&gt;Time#end_of_week&lt;&#x2F;code&gt;, &lt;code&gt;Time#end_of_year&lt;&#x2F;code&gt;, and &lt;code&gt;Time#end_of_quarter&lt;&#x2F;code&gt;, which all return exactly what you expect them to return:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;Time.now.end_of_week # =&amp;gt; Sun Mar 09 00:00:00 0800 2008&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Credit goes to &lt;a href=&quot;http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;5065-juanjo-baz-n&quot;&gt;Juanjo Bazán&lt;&#x2F;a&gt; (a former &lt;a href=&quot;http:&#x2F;&#x2F;weblog.workingwithrails.com&#x2F;2007&#x2F;10&#x2F;22&#x2F;hackfest-winner-interview-juanjo-bazn&quot;&gt;Rails Hackfest winner&lt;&#x2F;a&gt;) and &lt;a href=&quot;http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;7168-tarmo-t-nav&quot;&gt;Tarmo Tänav&lt;&#x2F;a&gt; for contributing this patch.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8934&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8934&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Date helpers now accept HTML options&lt;&#x2F;h3&gt;
&lt;p&gt;ActionView&#x27;s date helpers (such as &lt;code&gt;date_select&lt;&#x2F;code&gt;, &lt;code&gt;time_select&lt;&#x2F;code&gt;, &lt;code&gt;select_datetime&lt;&#x2F;code&gt;) did not support any HTML options, unlike the other helpers (like &lt;code&gt;f.text_field(:name, :class =&gt; &#x27;my_css_class&#x27;, :size =&gt; 20)&lt;&#x2F;code&gt;). This inconsistency has been fixed and you can now finally do:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;lt;%= date_select &#x27;user&#x27;, &#x27;birthday&#x27;, :order =&amp;gt; [:day], :class =&amp;gt; &#x27;my_css_class&#x27; %&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;&lt;a href=&quot;http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;5430-murray-steele&quot;&gt;Murray Steele&lt;&#x2F;a&gt; (h-lame on the Rails Trac) and &lt;a hre=&quot;http:&#x2F;&#x2F;mentalized.net&#x2F;&quot;&gt;Jakob Skjerning&lt;&#x2F;a&gt; contributed this patch.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8968&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8968&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;No need for explicit respond_to for RJS templates&lt;&#x2F;h3&gt;
&lt;p&gt;ActionController has been changed so that JS requests will automatically render action.js.rjs files without the need to specify an explicit &lt;code&gt;respond_to&lt;&#x2F;code&gt; block. This means that your .rjs files work the same way as your .html.erb files - just put them in the right place and Rails will use it.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8956&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8956&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Bugfixes&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8937 - Prevent Rails from crashing when trying to deserialize an XML representation of a model named &quot;Type&quot; (using Hash#from_xml). Contributed by &lt;a href=&quot;http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;5065-juanjo-baz-n&quot;&gt;Juanjo Bazán&lt;&#x2F;a&gt; and &lt;a href=&quot;http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;7102-isaac-feliu&quot;&gt;Isaac Feliu&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8942 - Fix eager loading so that it doesn&#x27;t pull in duplicate records in some cases. Contributed by Catfish.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;As usual, let me know of any inaccuracies or any suggestions you may have in the comments!&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #9 - the sleeper edition</title>
    <published>2008-02-27T09:56:49+00:00</published>
    <updated>2008-02-27T09:56:49+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/02/27/living-on-the-edge-of-rails-9-the-sleeper-edition/"/>
    <id>https://chuyeow.wtf/2008/02/27/living-on-the-edge-of-rails-9-the-sleeper-edition/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/02/27/living-on-the-edge-of-rails-9-the-sleeper-edition/">&lt;p&gt;It&#x27;s been a slow week on the Rails trunk this week in terms of exciting changes.&lt;&#x2F;p&gt;
&lt;p&gt;This week’s report covers changes from 18 Feb 2008 to 24 Feb 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveResource::Base now accepts user and password configuration&lt;&#x2F;h3&gt;
&lt;p&gt;You can now set the user and password for HTTP authentication in your ActiveResource models:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class Person &lt; ActiveResource::Base
  self.site = &#x27;http:&#x2F;&#x2F;example.com&#x2F;&#x27;
  self.user = &#x27;konata&#x27;
  self.password = &#x27;password&#x27;
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This is a better way to specify authentication credentials than the current way of doing it by putting it all in the site (e.g. &lt;code&gt;self.site = &#x27;http:&#x2F;&#x2F;konata:password@example.com&#x2F;&#x27;&lt;&#x2F;code&gt;).&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8891&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8891&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;script&#x2F;plugin install now supports SVN export&lt;&#x2F;h3&gt;
&lt;p&gt;You can now pass the &lt;code&gt;-e&#x2F;--export&lt;&#x2F;code&gt; option to &lt;code&gt;script&#x2F;plugin install&lt;&#x2F;code&gt; to do an Subversion export of the plugin. This allows you to then check in the plugin&#x27;s files into your own repository. Though seriously, if anyone really wants to do this, I&#x27;d suggest they use &lt;a href=&quot;http:&#x2F;&#x2F;piston.rubyforge.org&#x2F;&quot;&gt;Piston&lt;&#x2F;a&gt;. That is, for those of us still using Subversion rather than Git.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8921&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8921&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Bug fixes for associations preloading&lt;&#x2F;h3&gt;
&lt;p&gt;There&#x27;ve been some bug fixes the associations preloading change mentioned in &lt;a href=&quot;&#x2F;2008&#x2F;01&#x2F;30&#x2F;living-on-the-edge-of-rails-5-better-eager-loading-and-more&#x2F;&quot;&gt;Living on the edge #5&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8894&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8894&lt;&#x2F;a&gt; - Fixed a bug where associations that were preloaded (using nested &lt;code&gt;:includes&lt;&#x2F;code&gt;) errors out when the associations return &lt;code&gt;nil&lt;&#x2F;code&gt; (i.e. when there are no associated records).&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;ticket&#x2F;11154&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;ticket&#x2F;11154&lt;&#x2F;a&gt; - Fixed a bug where nested includes were assuming that all records are from the same class. This is not true for polymorphic associations, causing problems when they were being used.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Yup, that&#x27;s it for this week. As usual, let me know of anything I might have missed or any suggestions you may have in the comments!&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #8 - the code optimization edition</title>
    <published>2008-02-19T23:30:54+00:00</published>
    <updated>2008-02-19T23:30:54+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/02/19/living-on-the-edge-of-rails-8-the-code-optimization-edition/"/>
    <id>https://chuyeow.wtf/2008/02/19/living-on-the-edge-of-rails-8-the-code-optimization-edition/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/02/19/living-on-the-edge-of-rails-8-the-code-optimization-edition/">&lt;p&gt;Here&#x27;s this week&#x27;s update of the important changes that have been happening on edge Rails. There were lots of performance patches this week, credit mostly due to the guys from &lt;a href=&quot;http:&#x2F;&#x2F;www.acunote.com&#x2F;&quot;&gt;Acunote&lt;&#x2F;a&gt; and their latest &lt;a href=&quot;http:&#x2F;&#x2F;blog.pluron.com&#x2F;2008&#x2F;02&#x2F;rails-faster-as.html&quot;&gt;blog post on optimizing Rails&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;This week’s report covers changes from 11 Feb 2008 to 17 Feb 2008 (the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveRecord::Base#attributes-related optimizations&lt;&#x2F;h3&gt;
&lt;p&gt;The &lt;code&gt;ActiveRecord::Base#attributes_before_typecast&lt;&#x2F;code&gt; no longer clones attribute unnecessarily.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8858&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8858&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;&lt;code&gt;ActiveRecord::Base#attributes&lt;&#x2F;code&gt; now no longer supports options. The &lt;code&gt;ActiveRecord::Base#attributes&lt;&#x2F;code&gt; method used to support &lt;code&gt;:only&lt;&#x2F;code&gt; and &lt;code&gt;:except&lt;&#x2F;code&gt; options, which are actually unnecessary since it returns a Hash. You can use &lt;code&gt;Hash#slice&lt;&#x2F;code&gt; or &lt;code&gt;Hash#except&lt;&#x2F;code&gt; (both ActiveSupport core extensions) directly on the hash.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8863&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8863&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveRecord associations optimized by avoiding named block arguments&lt;&#x2F;h3&gt;
&lt;p&gt;Alexander Dymo is at it again optimizing ActiveRecord performance, this time by avoiding passing named block arguments. Turns out that it is faster and more memory efficient in Ruby to pass blocks like this:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def foo
  bar { |*block_args| yield(*block_args) if block_given?
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;instead of passing the block around like so:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;def foo(&amp;&amp;amp;block)
  bar(&amp;amp;block)
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Occurrences of the more expensive way of passing blocks have been replaced in the ActiveRecord associations code so associations are lighter to use.&lt;&#x2F;p&gt;
&lt;p&gt;For a more detailed write-up, check out &lt;a href=&quot;http:&#x2F;&#x2F;blog.pluron.com&#x2F;2008&#x2F;02&#x2F;rails-faster-as.html&quot;&gt;Alexander&#x27;s blog entry&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8865&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8865&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveRecord associations optimized by using symbol callbacks instead of string callbacks&lt;&#x2F;h3&gt;
&lt;p&gt;Again from Alexander Dymo, this patch also improving ActiveRecord association performance. Internally, ActiveRecord associations code uses a lot of string callbacks (e.g. &lt;code&gt;before_save &quot;some_ruby_code_to_eval&quot;&lt;&#x2F;code&gt;). It turns out that that is significantly more expensive compared to simply using &lt;code&gt;Module#define_method&lt;&#x2F;code&gt; because when the callback string is evaluated, the binding needs to be passed along. Passing the binding takes up memory (which is bad, of course).&lt;&#x2F;p&gt;
&lt;p&gt;The internal associations code has been changed to use that &lt;code&gt;define_method&lt;&#x2F;code&gt; now, and if you&#x27;re using a lot of associations, you would save megabytes of memory! (&lt;a href=&quot;http:&#x2F;&#x2F;blog.pluron.com&#x2F;2008&#x2F;02&#x2F;rails-faster-as.html&quot;&gt;Alexander&#x27;s blog post&lt;&#x2F;a&gt; has more detailed benchmarks.)&lt;&#x2F;p&gt;
&lt;p&gt;Remember, when writing your own before and after filters, not to use a string that needs to be &lt;code&gt;eval&lt;&#x2F;code&gt;ed!&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8867&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8867&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Improve ActiveRecord::Base#save performance by avoiding repeated calls to ActiveRecord::Base#connection&lt;&#x2F;h3&gt;
&lt;p&gt;Another Alexander Dymo performance patch. This particular patch improves performance by getting the connection object just once and calling it directly, instead of needlessly calling several times. This should improve &lt;code&gt;ActiveRecord::Base#save&lt;&#x2F;code&gt; performance.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8871&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8871&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveRecord associations now support the :readonly option&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;ActiveRecord::Base#find&lt;&#x2F;code&gt; supports the &lt;code&gt;:readonly&lt;&#x2F;code&gt; option to retrieve records that were read-only (i.e. you couldn&#x27;t save them). Now you can do the same for associations, like so:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;has_many :comments, :readonly =&gt; true&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This allows you to protect associated records from being saved.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8864&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8864&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;String#squish and String#squish! to remove consecutive chunks of whitespace&lt;&#x2F;h3&gt;
&lt;p&gt;A &lt;code&gt;String#squish&lt;&#x2F;code&gt; extension has been added that trims whitespace from both ends of a string, and compressing consecutive whitespace groups within the string into 1 space each.&lt;&#x2F;p&gt;
&lt;p&gt;For example,&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;@description = %{ String#squish() allows me to write long strings
  inside my Ruby code, without having to worry about indentation,
  the page margin, spaces, tabs or newlines. &quot;double&quot; or &#x27;single&#x27;
  quotes are both fine, and #{interpolation} works. }.squish
&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8878&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8878&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As always, let me know of any inaccuracies or any suggestions you may have in the comments, see you guys next week!&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #7 - improved ActiveRecord::Base#attributes, time zone support</title>
    <published>2008-02-13T23:49:44+00:00</published>
    <updated>2008-02-13T23:49:44+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/02/13/living-on-the-edge-of-rails-7-improved-activerecordbaseattributes-time-zone-support/"/>
    <id>https://chuyeow.wtf/2008/02/13/living-on-the-edge-of-rails-7-improved-activerecordbaseattributes-time-zone-support/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/02/13/living-on-the-edge-of-rails-7-improved-activerecordbaseattributes-time-zone-support/">&lt;p&gt;It&#x27;s that time of the week again (every Wednesday for the overly observant, coinciding with the release of the &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;2008&#x2F;2&#x2F;13&#x2F;rails-envy-podcast-episode-018-2-13-2008&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt;) for some choice updates of what changes have been happening on edge Rails. This week&#x27;s report covers changes from 4 Feb 2008 to 10 Feb 2008 (the day the &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;2008&#x2F;2&#x2F;13&#x2F;rails-envy-podcast-episode-018-2-13-2008&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;More efficent ActiveRecord::Base#attributes&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;ActiveRecord::Base#attributes&lt;&#x2F;code&gt; returns a hash of all attributes with clones of their objects as values. This unnecessary cloning is expensive, and has now been removed. &lt;code&gt;ActiveRecord::Base#attributes&lt;&#x2F;code&gt; now returns a hash of &lt;em&gt;values&lt;&#x2F;em&gt; of the attributes.&lt;&#x2F;p&gt;
&lt;p&gt;Thanks to Juanjo Bazan, there have been 2 further patches (after the podcast was recorded) related &lt;code&gt;ActiveRecord::Base#attributes&lt;&#x2F;code&gt; that further improves ActiveRecord&#x27;s performance: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8858&quot;&gt;removal of cloning from &lt;code&gt;ActiveRecord::Base#attributes_before_typecast&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;, and &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8863&quot;&gt;removing options (&lt;code&gt;:only&lt;&#x2F;code&gt; and &lt;code&gt;:except&lt;&#x2F;code&gt; options, specifically) from &lt;code&gt;ActiveRecord::Base#attributes&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8824&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8824&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveResouce::Base#exists? now uses HTTP HEAD instead of a GET&lt;&#x2F;h3&gt;
&lt;p&gt;A &lt;a href=&quot;http:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;HTTP#Request_Methods&quot;&gt;HTTP HEAD&lt;&#x2F;a&gt; request is really all that is needed to check for existence (200 == exists, 404 == doesn&#x27;t exist). This has been changed to HEAD from a GET request, which is more efficient since all we retrieve are the HTTP headers and there&#x27;s no unnecessary instantiation of the ActiveResource object.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8827&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8827&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Time zone support for ActiveRecord, and config.time_zone property for specifying a default Time Zone&lt;&#x2F;h3&gt;
&lt;p&gt;ActiveRecord models now have time zone-aware attribute readers and writers. Times returned from ActiveRecord attribute readers now have a &lt;code&gt;time_zone&lt;&#x2F;code&gt; attribute themselves, allowing time zone-aware calculations.&lt;&#x2F;p&gt;
&lt;p&gt;You can now configure the default &lt;code&gt;Time.zone&lt;&#x2F;code&gt; value with &lt;code&gt;config.time_zone&lt;&#x2F;code&gt; in your &lt;code&gt;environment.rb&lt;&#x2F;code&gt;. Setting this will enable time zone-awareness for ActiveRecord models.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8806&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8806&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;A Template class has been introduced to ActionView&lt;&#x2F;h3&gt;
&lt;p&gt;As part of the ActionPack refactoring that&#x27;s still ongoing, a &lt;code&gt;ActionView::Template&lt;&#x2F;code&gt; class has been introduced to encapsulate all the data relevant to the currently rendered template. This is largely an internal refactoring so Rails users shouldn&#x27;t be affected.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8805&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8805&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Concrete sweeper classes&lt;&#x2F;h3&gt;
&lt;p&gt;You can now use an explicit class when declaring a cache_sweeper. E.g.&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class ListsController &amp;lt; ApplicationController 
  caches_action :index, :show, :public, :feed 
  cache_sweeper Sweepers::List, :only =&amp;gt; [ :edit, :destroy, :share ] 
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8819&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8819&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As always, let me know of any inaccuracies or any suggestions you may have in the comments - this week&#x27;s report is a little rushed because I&#x27;m a little late in posting it up!&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #6 - better performance, Git support, and more</title>
    <published>2008-02-06T21:54:37+00:00</published>
    <updated>2008-02-06T21:54:37+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/02/06/living-on-the-edge-of-rails-6-better-performance-git-support-and-more/"/>
    <id>https://chuyeow.wtf/2008/02/06/living-on-the-edge-of-rails-6-better-performance-git-support-and-more/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/02/06/living-on-the-edge-of-rails-6-better-performance-git-support-and-more/">&lt;p&gt;Here&#x27;s another week of noteworthy updates on the Rails trunk. Thanks once again to the &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; for featuring my updates, and even bigger thanks to the Rails contributors and committers who make things happen. This week&#x27;s Living on the Edge was covered in &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;2008&#x2F;2&#x2F;6&#x2F;ruby-on-rails-podcast&quot;&gt;Rails Envy podcast #17&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The company I work for, &lt;a href=&quot;http:&#x2F;&#x2F;bezurk.com&#x2F;&quot;&gt;Bezurk&lt;&#x2F;a&gt; (yeah we know some of you hate the name &quot;Bezurk&quot; - that&#x27;s going to change), is currently looking for a Ruby developer to join our ranks. This person will be working mainly on Ruby-based web development projects. As we all know, &quot;Rails doesn&#x27;t scale&quot; (delivered in Jason Seifer-style - meaning it&#x27;s just a joke!) so we&#x27;d love anyone who&#x27;s up for a challenge and who&#x27;s also willing to work outside the Rails comfort zone (our current favorite: &lt;a href=&quot;http:&#x2F;&#x2F;ramaze.net&#x2F;&quot;&gt;Ramaze&lt;&#x2F;a&gt;). Our Ruby team currently comprises 3 experienced developers and 1 up and coming Rubyist.&lt;&#x2F;p&gt;
&lt;p&gt;We&#x27;re active Open Source contributors (Arun released &lt;a href=&quot;http:&#x2F;&#x2F;code.google.com&#x2F;p&#x2F;activecouch&#x2F;&quot;&gt;ActiveCouch&lt;&#x2F;a&gt; recently), while I am a Rails contributor (I&#x27;m &#x27;chuyeow&#x27; on the &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;&quot;&gt;Rails Trac&lt;&#x2F;a&gt;) myself.&lt;&#x2F;p&gt;
&lt;p&gt;If all this sounds interesting enough to you, do check out the &lt;a href=&quot;http:&#x2F;&#x2F;jobs.monster.com.sg&#x2F;details&#x2F;4917397.html&quot;&gt;full job description&lt;&#x2F;a&gt; and drop us an email. Yes, we&#x27;re serious when we said &quot;+1 for DotA&#x2F;Counterstrike skills)&quot;. There&#x27;s a catch though - you have to work on location at our office in Singapore.&lt;&#x2F;p&gt;
&lt;p&gt;Anyway, let&#x27;s get back on topic - this weeks’ report covers changes from 28 Jan 2008 to 3 Feb 2008 (the day the Rails Envy podcast was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;Saving, creating and updating ActiveRecord objects is more efficient&lt;&#x2F;h3&gt;
&lt;p&gt;Thanks to Gleb Arshinov and Alexander Dymo with their &lt;a href=&quot;http:&#x2F;&#x2F;blog.pluron.com&#x2F;2008&#x2F;01&#x2F;ruby-on-rails-i.html&quot;&gt;blog post and patches about improving Rails performance&lt;&#x2F;a&gt; by approaching it via minimizing garbage collection, saving, creating, and updating ActiveRecord objects is now significantly more efficient.&lt;&#x2F;p&gt;
&lt;p&gt;The expensive &lt;code&gt;ActiveRecord::Base#attributes&lt;&#x2F;code&gt; method is no longer called internally, so there&#x27;s no unnecessary cloning of attribute values. Less memory usage means less garbage collection, which means better performance!&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8770&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8770&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;SQL calls and rendering are faster&lt;&#x2F;h3&gt;
&lt;p&gt;This patch is courtesy of &lt;a href=&quot;http:&#x2F;&#x2F;blog.pluron.com&#x2F;2008&#x2F;01&#x2F;ruby-on-rails-i.html&quot;&gt;Gleb Arshinov and Alexander Dymo&lt;&#x2F;a&gt; too.&lt;&#x2F;p&gt;
&lt;p&gt;Rails surrounds every SQL call and &lt;code&gt;ActionView::Base#render&lt;&#x2F;code&gt; with the ruby method &lt;code&gt;Benchmark#realtime&lt;&#x2F;code&gt; so that it can print out some benchmarking numbers. &lt;code&gt;Benchmark#realtime&lt;&#x2F;code&gt; allocates an unnecessary 45k of memory per call (who knew!). This has been monkey patched in Rails to a leaner implementation, reducing memory usage and increasing performance.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8771&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8771&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;MySQL adapter slight optimization&lt;&#x2F;h3&gt;
&lt;p&gt;Table and column names in the MySQL adapter are now cached in instance variables, reducing memory allocations (and thus the need for &lt;acronym title=&quot;garbage collection&quot;&gt;GC&lt;&#x2F;acronym&gt;).&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8794&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8794&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;script&#x2F;generate does Git!&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;script&#x2F;generate&lt;&#x2F;code&gt; now allows you to pass the &#x27;--git&#x27; (or &#x27;-g&#x27;) option to add the generated files to git (much like how you could do the same with Subversion with &#x27;-c&#x27; or &#x27;--svn&#x27;). This patch is the work of &lt;a href=&quot;http:&#x2F;&#x2F;blog.stevensoroka.ca&#x2F;&quot;&gt;Steven Soroka&lt;&#x2F;a&gt; so nice work Steven!&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8772&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8772&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;map.resources :products, :as =&gt; &#x27;something_else&#x27;&lt;&#x2F;h3&gt;
&lt;p&gt;Here&#x27;s something that will make non-english Rails developers happy: you can now do, for example,&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;map.resources :comments, :as =&gt; &#x27;comentarios&#x27;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;so that you can keep having your model names independent of what URLs you&#x27;d actually like to appear on the site.&lt;&#x2F;p&gt;
&lt;p&gt;The above &lt;code&gt;map.resources&lt;&#x2F;code&gt; means that you can keep your resource and model names in English (Comment), while having URLs like this: &#x2F;comentarios&#x2F;123.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8785&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8785&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;:index option for form_for and fields_for to simplify multi-model forms&lt;&#x2F;h3&gt;
&lt;p&gt;Inspired by a &lt;a href=&quot;http:&#x2F;&#x2F;railscasts.com&#x2F;episodes&#x2F;75&quot;&gt;Railscasts episode&lt;&#x2F;a&gt; where Ryan Bates mentions how ugly it is to have to pass &lt;code&gt;:index =&gt; nil&lt;&#x2F;code&gt; to prevent &lt;code&gt;#text_field&lt;&#x2F;code&gt; (and other form helpers) from inserting the model&#x27;s ID in the input name (e.g. project[task_attributes][123][name] when what you really want is project[task_attributes][][name]).&lt;&#x2F;p&gt;
&lt;p&gt;Meaning instead of&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;lt;% fields_for &quot;project[task_attributes][]&quot;, task do |f| %&amp;gt;
  &amp;lt;%= f.text_field :name, :index =&amp;gt; nil %&amp;gt;
  &amp;lt;%= f.hidden_field :id, :index =&amp;gt; nil %&amp;gt;
&amp;lt;% end %&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;you can now do:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;lt;% fields_for &quot;project[task_attributes][]&quot;, task, :index =&amp;gt; nil do |f| %&amp;gt;
  &amp;lt;%= f.text_field :name %&amp;gt;
  &amp;lt;%= f.hidden_field :id %&amp;gt;
&amp;lt;% end %&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8786&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8786&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;No more emails in your production logs&lt;&#x2F;h3&gt;
&lt;p&gt;You&#x27;d probably have noticed that ActionMailer logs &lt;em&gt;entire&lt;&#x2F;em&gt; email messages in the log, even in production. Well, it&#x27;s been changed to be less verbose now. At the &lt;code&gt;:info&lt;&#x2F;code&gt; log level, only the recipients are logged. You can still see the entire email at the &lt;code&gt;:debug&lt;&#x2F;code&gt; log level (which is the default for development environment).&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8781&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8781&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As always, let me know of any inaccuracies or any suggestions you may have in the comments. Oh, and if you liked this, do me a favor by &lt;a href=&quot;http:&#x2F;&#x2F;reddit.com&#x2F;r&#x2F;ruby&#x2F;submit&quot;&gt;submitting it to Ruby Reddit&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #5 - better eager loading and more</title>
    <published>2008-01-30T18:26:39+00:00</published>
    <updated>2008-01-30T18:26:39+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/01/30/living-on-the-edge-of-rails-5-better-eager-loading-and-more/"/>
    <id>https://chuyeow.wtf/2008/01/30/living-on-the-edge-of-rails-5-better-eager-loading-and-more/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/01/30/living-on-the-edge-of-rails-5-better-eager-loading-and-more/">&lt;p&gt;Another week of edge Rails changes, featured on the &lt;a href=&quot;http:&#x2F;&#x2F;www.railsenvy.com&#x2F;podcast&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt;. This weeks’ report covers changes from 21 Jan 2008 to 27 Jan 2008 (the day the &lt;a href=&quot;http:&#x2F;&#x2F;www.railsenvy.com&#x2F;podcast&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;Eager loading :includes does pre-loading&lt;&#x2F;h3&gt;
&lt;p&gt;The current gem Rails behavior when loading associations with something like&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;Author.find(:all, :include =&gt; [:posts, :comments])&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;is to make a big query with multiple joins that fetches all the associations in the same query (for you RDBMS geeks, the &quot;cartesian product&quot;).&lt;&#x2F;p&gt;
&lt;p&gt;Frederick Cheung (fcheung on the Rails Trac) has contributed an impressive optimization to this by pre-loading the associations rather than trying to eager loading with one big query. So a find like this:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;Author.find(:all, :include =&gt; [:posts, :comments])&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;would first load all the authors, then all the posts, and then all the comments in 3 smaller, faster queries.&lt;&#x2F;p&gt;
&lt;p&gt;The main benefit of this (depending on your data): Running X simple queries (to fetch authors, then posts and comments) rather than one mega-query that joins all the associated tables is faster most of the time. The result set is often smaller as well.&lt;&#x2F;p&gt;
&lt;p&gt;More details can be found at &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;ticket&#x2F;9640&quot;&gt;ticket #9640 on the Rails Trac&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8672&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8672&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;&lt;code&gt;composed_of&lt;&#x2F;code&gt; aggregations can now be used in finder conditions&lt;&#x2F;h3&gt;
&lt;p&gt;You can now use value objects that you&#x27;ve previously specified that your model is &lt;code&gt;composed_of&lt;&#x2F;code&gt; in the finder conditions hash. E.g. if you have a Customer that has a balance aggregation:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class Customer &amp;lt; ActiveRecord::Base
  composed_of :balance, :class_name =&amp;gt; &quot;Money&quot;, :mapping =&amp;gt; %w(balance amount)
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;You can now pass a Money value object to &lt;code&gt;Customer#find&lt;&#x2F;code&gt;:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;Customer.find(:all, :conditions =&amp;gt; { :balance =&amp;gt; Money.new(20, &quot;USD&quot;) })&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Convenient.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8671&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8671&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;New helper: label_tag&lt;&#x2F;h3&gt;
&lt;p&gt;A &lt;code&gt;label_tag&lt;&#x2F;code&gt; helper has been missing for quite awhile since the label helper was added. No longer:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;label_tag &#x27;name&#x27;
# =&amp;gt; &amp;lt;label for=&quot;name&quot;&amp;gt;Name&amp;lt;&#x2F;label&amp;gt;
&lt;p&gt;label_tag &#x27;name&#x27;, &#x27;Your name&#x27;&lt;&#x2F;p&gt;
&lt;h1 id=&quot;label-for-name-your-name-label&quot;&gt;=&amp;gt; &amp;lt;label for=&quot;name&quot;&amp;gt;Your name&amp;lt;&#x2F;label&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;&#x2F;h1&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8685&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8685&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;New ActiveSupport class: ActiveSupport::TimeWithZone&lt;&#x2F;h3&gt;
&lt;p&gt;A new &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;browser&#x2F;trunk&#x2F;activesupport&#x2F;lib&#x2F;active_support&#x2F;time_with_zone.rb&quot;&gt;&lt;code&gt;ActiveSupport::TimeWithZone&lt;&#x2F;code&gt; class&lt;&#x2F;a&gt; has been introduced to make timezone support in Rails easier. Ryan Daigle has a &lt;a href=&quot;http:&#x2F;&#x2F;ryandaigle.com&#x2F;articles&#x2F;2008&#x2F;1&#x2F;25&#x2F;what-s-new-in-edge-rails-easier-timezones&quot;&gt;good writeup&lt;&#x2F;a&gt; on this.&lt;&#x2F;p&gt;
&lt;p&gt;A word of warning though: this is still work in progress, as Geoff Buesing, the core team member responsible for these timezone changes, has more to add on how his &lt;a href=&quot;http:&#x2F;&#x2F;ryandaigle.com&#x2F;articles&#x2F;2008&#x2F;1&#x2F;25&#x2F;what-s-new-in-edge-rails-easier-timezones#comment-6450&quot;&gt;plans for the timezone puzzle in the comments&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8696&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8696&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;map.root can be easily aliased&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;map.root&lt;&#x2F;code&gt; now accept a single symbol as an argument to declare an alias. Just a little something to keep your routes a little more DRY, e.g.:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;map.new_session :controller =&amp;gt; &#x27;sessions&#x27;, :action =&amp;gt; &#x27;new&#x27; 
map.root :new_session&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8738&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8738&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;p&gt;As usual, let me know of any inaccuracies or any suggestions you may have in the comments!&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the edge (of Rails) #4 - faster routes, easier form partials</title>
    <published>2008-01-23T19:54:46+00:00</published>
    <updated>2008-01-23T19:54:46+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/01/23/living-on-the-edge-of-rails-4-faster-routes-easier-form-partials/"/>
    <id>https://chuyeow.wtf/2008/01/23/living-on-the-edge-of-rails-4-faster-routes-easier-form-partials/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/01/23/living-on-the-edge-of-rails-4-faster-routes-easier-form-partials/">&lt;p&gt;It&#x27;s time again for your weekly dose of what&#x27;s new in edge Rails. This weeks&#x27; report covers changes from 14 Jan 2008 to 20 Jan 2008 (the day the &lt;a href=&quot;http:&#x2F;&#x2F;railsenvy.com&#x2F;podcast&#x2F;&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded).&lt;&#x2F;p&gt;
&lt;h3&gt;Route recognition is faster&lt;&#x2F;h3&gt;
&lt;p&gt;Rails&#x27; route recognition has been optimized and is significantly faster especially for applications using many resources (i.e. via &lt;code&gt;map.resources&lt;&#x2F;code&gt; in your &lt;code&gt;config&#x2F;routes.rb&lt;&#x2F;code&gt;). Big thumbs up to Oleg Andreev (aka oleganza) who also &lt;a href=&quot;http:&#x2F;&#x2F;www.novemberain.com&#x2F;2008&#x2F;1&#x2F;17&#x2F;routes-recognition&quot;&gt;wrote a detailed post about it&lt;&#x2F;a&gt;. You can also find out more about how this works in the &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;browser&#x2F;trunk&#x2F;actionpack&#x2F;lib&#x2F;action_controller&#x2F;routing&#x2F;recognition_optimisation.rb&quot;&gt;code comments&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changesets: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8674&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8674&lt;&#x2F;a&gt; and &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8652&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8652&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3&gt;render :partial and forms&lt;&#x2F;h3&gt;
&lt;p&gt;Instead of doing:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;lt;% form_for(:person) do |f| %&amp;gt;
  &amp;lt;%= render :partial =&amp;gt; &#x27;form&#x27;, :locals =&amp;gt; { :form =&amp;gt; f } %&amp;gt;
&amp;lt;% end %&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;you can now do:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;lt;% form_for(:person) do |f| %&amp;gt;
  &amp;lt;%= render :partial =&amp;gt; f %&amp;gt;
&amp;lt;% end %&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Convenient. This also works with your &lt;a href=&quot;http:&#x2F;&#x2F;api.rubyonrails.org&#x2F;classes&#x2F;ActionView&#x2F;Helpers&#x2F;FormHelper.html#M000920&quot;&gt;custom form builders&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;&amp;lt;% form_for(:person, :builder =&amp;gt; LabellingFormBuilder) do |f| %&amp;gt;
  &amp;lt;%= render :partial =&amp;gt; f %&amp;gt;
&amp;lt;% end %&amp;gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The partial template rendered is then &lt;code&gt;people&#x2F;_labelling_form&lt;&#x2F;code&gt; and the local variable in the partial is &lt;code&gt;labelling_form&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8646&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8646&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3&gt;Callbacks refactored into ActiveSupport::Callbacks&lt;&#x2F;h3&gt;
&lt;p&gt;All that duplicated callback code in ActiveRecord, ActionController::Dispatcher, and in test case setup and teardown methods have been extracted into the ActiveSupport::Callbacks module.&lt;&#x2F;p&gt;
&lt;p&gt;Less duplication means more robust code so yay!&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8664&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8664&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveRecord test suite gets a makeover&lt;&#x2F;h3&gt;
&lt;p&gt;The ActiveRecord test suite has become something of a maze jungle in recent times, with no clear hierarchy of how things are organize. It&#x27;s not that easy to find what you are looking for especially for newcomers trying to contribute to ActiveRecord. Thankfully, someone (John Barnette - the foxy fixtures guy) has stepped up and cleaned things up quite a bit. Fixtures, test cases, fixture models, etc. are now in their own directories and from looking at the directory hierarchy one should be able to know where to put what at a glance.&lt;&#x2F;p&gt;
&lt;p&gt;Related ticket: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;ticket&#x2F;10742&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;ticket&#x2F;10742&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3&gt;Bugfixes&lt;&#x2F;h3&gt;
&lt;p&gt;* &lt;code&gt;redirect_to nil&lt;&#x2F;code&gt; no longer explodes (but raises a friendlier &#x27;cannot redirect to nil&#x27; exception) (related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8633&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8633&lt;&#x2F;a&gt;).&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the Edge (of Rails) #3 - X-Sendfile and many other sexy enhancements</title>
    <published>2008-01-16T23:25:48+00:00</published>
    <updated>2008-01-16T23:25:48+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/01/16/living-on-the-edge-of-rails-3-x-sendfile-and-many-other-sexy-enhancements/"/>
    <id>https://chuyeow.wtf/2008/01/16/living-on-the-edge-of-rails-3-x-sendfile-and-many-other-sexy-enhancements/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/01/16/living-on-the-edge-of-rails-3-x-sendfile-and-many-other-sexy-enhancements/">&lt;p&gt;Edge Rails saw a barrage of refinements and enhancements this week and there&#x27;s even talk about Rails 2.1 being just a little around the corner. There&#x27;s also been a flurry of contributions to making Rails more thread-safe and performance optimizations (all still work in progress at the moment) - it&#x27;s really nice to see how the Rails community is looking seriously at performance post-Rails 2.0 (not that they weren&#x27;t serious about performance before Rails 2.0!).&lt;&#x2F;p&gt;
&lt;p&gt;This week’s report covers changes from 7 Jan 2008 to the day the corresponding &lt;a href=&quot;http:&#x2F;&#x2F;www.railsenvy.com&#x2F;2008&#x2F;1&#x2F;16&#x2F;rails-envy-podcast-episode-014-1-16-2008&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt; was recorded (13 Jan 2008).&lt;&#x2F;p&gt;
&lt;h3&gt;X-Sendfile gets easier with send_file :x_sendfile =&gt; true&lt;&#x2F;h3&gt;
&lt;p&gt;If you only have a vague idea of what it is (like, X-Sendfile is that thing that lets you send files, right?), you&#x27;d do well to read this &lt;a href=&quot;http:&#x2F;&#x2F;john.guen.in&#x2F;past&#x2F;2007&#x2F;4&#x2F;17&#x2F;send_files_faster_with_xsendfile&#x2F;&quot;&gt;helpful explanation&lt;&#x2F;a&gt;. (In short, X-Sendfile allows you to send static files directly and more performantly to HTTP clients and bypassing your app server process.) You don&#x27;t have to set those headers yourself or install the plugin mentioned in that article though, since edge Rails has an augmented &lt;a href=&quot;http:&#x2F;&#x2F;api.rubyonrails.org&#x2F;classes&#x2F;ActionController&#x2F;Streaming.html#M000228&quot;&gt;&lt;code&gt;send_file&lt;&#x2F;code&gt;&lt;&#x2F;a&gt; helper that does all the legwork for you.&lt;&#x2F;p&gt;
&lt;p&gt;All you have to do now is to this:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;send_file &#x27;&#x2F;path&#x2F;to.png&#x27;, :x_sendfile =&amp;gt; true, :type =&amp;gt; &#x27;image&#x2F;png&#x27;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Rails will set the X-Sendfile header for you (i.e. &lt;code&gt;response.headers[&#x27;X-Sendfile&#x27;] = &#x27;&#x2F;path&#x2F;to.png&#x27;&lt;&#x2F;code&gt;) and sends a HEAD response (empty response body) with the file path, allowing your web server (Apache, Lighttpd) to serve the static file and not involve your Rails processes (such as your precious, perpertually resource-starved &lt;a href=&quot;http:&#x2F;&#x2F;mongrel.rubyforge.org&#x2F;&quot;&gt;mongrels&lt;&#x2F;a&gt;).&lt;&#x2F;p&gt;
&lt;p&gt;This is &lt;em&gt;really&lt;&#x2F;em&gt; nice if you are serving lots of static files (downloadable images and documents come to mind) and are not already using X-Sendfile or doing it the &quot;long&quot; way (by setting the response header and then &lt;code&gt;render :nothing =&gt; true&lt;&#x2F;code&gt;).&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8628&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8628&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;ActionController::Base.asset_host proc now takes the request object as an optional 2nd argument&lt;&#x2F;h3&gt;
&lt;p&gt;Rails 2.0.2 allowed you to set &lt;code&gt;ActionController::Base.asset_host&lt;&#x2F;code&gt; to a proc that took a single &lt;code&gt;source&lt;&#x2F;code&gt; argument (as &lt;a href=&quot;https:&#x2F;&#x2F;chuyeow.wtf&#x2F;2007&#x2F;12&#x2F;17&#x2F;rails-202-released-so-whats-new&#x2F;&quot;&gt;detailed in my earlier post&lt;&#x2F;a&gt;). People were still &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;ticket&#x2F;10549&quot;&gt;running into problems&lt;&#x2F;a&gt; with asset hosting though, particularly while trying to serve assets from an SSL-protected page (i.e. HTTPS requests). When serving SSL-protected pages, you&#x27;d need to either have an SSL certificate for each asset host(!) or live with a mixed media warning (which browsers report when you have SSL and non-SSL content on the same page).&lt;&#x2F;p&gt;
&lt;p&gt;The &lt;code&gt;asset_host&lt;&#x2F;code&gt; proc now takes the entire controller request instance as an optional second argument. This allows you to either use a single asset host or to disable asset hosting for SSL requests. For example, this proc below practically disables asset hosting:&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;ActionController::Base.asset_host = Proc.new { |source, request| 
  if request.ssl? 
    &quot;#{request.protocol}#{request.host_with_port}&quot; # Disable asset hosting.
  else 
    &quot;#{request.protocol}assets.example.com&quot; # Use asset host.
  end 
}&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8578&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8578&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Nicer way to access request headers&lt;&#x2F;h3&gt;
&lt;p&gt;There&#x27;s now a nicer way to access headers - instead of &lt;code&gt;request.env[&quot;HTTP_CONTENT_TYPE&quot;]&lt;&#x2F;code&gt; you can now do &lt;code&gt;request.headers[&quot;Content-Type&quot;]&lt;&#x2F;code&gt; (or &lt;code&gt;request.headers[&quot;content-type&quot;]&lt;&#x2F;code&gt; (note all lowercase) or even good old &lt;code&gt;request.headers[&quot;HTTP_CONTENT_TYPE&quot;]&lt;&#x2F;code&gt;. How convenient - I often worry about getting the casing right (was it &#x27;Content-Type&#x27; or &#x27;Content-type&#x27;?) and now I can be sure it doesn&#x27;t matter!&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8625&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8625&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;ActiveSupport::TestCase and friends now support declarative setup and teardown callbacks&lt;&#x2F;h3&gt;
&lt;p&gt;&lt;code&gt;ActiveSupport::TestCase&lt;&#x2F;code&gt; (and the &lt;code&gt;ActionController::TestCase&lt;&#x2F;code&gt; and &lt;code&gt;ActionMailer::TestCase&lt;&#x2F;code&gt; subclasses) now support declarative setup and teardown callbacks that are called before setup&#x2F;after teardown. For example,&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class FooTestCase &amp;lt; ActiveSupport::TestCase
  setup :run_this_first, :then_run_this do
    # Run this last.
  end
  teardown :remove_tmp_files, :undef_constants
&lt;p&gt;def run_this_first
end&lt;&#x2F;p&gt;
&lt;p&gt;def then_run_this
end&lt;&#x2F;p&gt;
&lt;p&gt;def remove_tmp_files
end&lt;&#x2F;p&gt;
&lt;p&gt;def undef_constants
end
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;&#x2F;p&gt;
&lt;p&gt;will run &lt;code&gt;run_this_first&lt;&#x2F;code&gt;, &lt;code&gt;then_run_this&lt;&#x2F;code&gt;, and finally the stuff that&#x27;s in the given block to &#x27;setup&#x27; before running the actual &lt;code&gt;setup&lt;&#x2F;code&gt; method. The teardown callbacks are done in reverse order, meaning &lt;code&gt;undef_constants&lt;&#x2F;code&gt; is called, and then &lt;code&gt;remove_tmp_files&lt;&#x2F;code&gt; (and then the actual &lt;code&gt;teardown&lt;&#x2F;code&gt; method).&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8570&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8570&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;TMail updated to 1.2.1&lt;&#x2F;h3&gt;
&lt;p&gt;The bundled &lt;a href=&quot;http:&#x2F;&#x2F;tmail.rubyforge.org&#x2F;&quot;&gt;TMail&lt;&#x2F;a&gt; library (that ActionMailer uses) has been updated from 1.1.0 to 1.2.1. This new version currently maintained by &lt;a href=&quot;http:&#x2F;&#x2F;lindsaar.net&#x2F;&quot;&gt;Mikel Lindsaar&lt;&#x2F;a&gt; promises bugfixes and greater test coverage. For more details, see &lt;a href=&quot;https:&#x2F;&#x2F;rubyforge.org&#x2F;frs&#x2F;shownotes.php?group_id=4512&amp;release_id=18049&quot;&gt;https:&#x2F;&#x2F;rubyforge.org&#x2F;frs&#x2F;shownotes.php?group_id=4512&amp;release_id=18049&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Mikel has been working with Rails core to get Tmail Ruby 1.9-compatible. Good work Mikel!&lt;&#x2F;p&gt;
&lt;p&gt;Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8620&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8620&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
&lt;h3&gt;Bug fixes&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;
    &lt;code&gt;ActionController::UrlWriter&lt;&#x2F;code&gt; respects the &lt;code&gt;relative_url_root&lt;&#x2F;code&gt;. For those of you who don&#x27;t know, the &lt;code&gt;ActionController::UrlWriter&lt;&#x2F;code&gt; module is a convenient mixin that allows you to use &lt;code&gt;url_for&lt;&#x2F;code&gt; &lt;em&gt;and&lt;&#x2F;em&gt; your named routes in arbitrary classes (such as in your mailers or in a BackgrounDRb worker).&lt;&#x2F;p&gt;
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class SitemapWorker &amp;lt; BackgrounDRb::MetaWorker
  &lt;strong&gt;include ActionController::UrlWriter&lt;&#x2F;strong&gt;
&lt;h1 id=&quot;access-your-named-routes-and-the-url-for-helper&quot;&gt;Access your named routes and the url_for helper.&lt;&#x2F;h1&gt;
&lt;p&gt;url = page_url(:permalink =&amp;gt; &#x27;foo&#x27;)
end&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;&#x2F;p&gt;
&lt;p&gt;  And now it respects your &lt;code&gt;relative_url_root&lt;&#x2F;code&gt; instead of blissfully ignoring it.&lt;&#x2F;p&gt;
&lt;p&gt;  Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8616&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8616&lt;&#x2F;a&gt;
  &lt;&#x2F;li&gt;
&lt;li&gt;
    &lt;code&gt;render :text =&gt; nil&lt;&#x2F;code&gt; and &lt;code&gt;render :text =&gt; false&lt;&#x2F;code&gt; work properly now instead of inexplicably trying to render a file. This was a big gotcha when using &lt;code&gt;render :text =&gt; some_variable&lt;&#x2F;code&gt; where &lt;code&gt;some_variable&lt;&#x2F;code&gt; could potentially be false or nil in some cases - Obie Fernandez has a &lt;a href=&quot;http:&#x2F;&#x2F;www.jroller.com&#x2F;obie&#x2F;entry&#x2F;render_text_gotcha&quot;&gt;writeup on this long-standing bug&lt;&#x2F;a&gt;. Related changeset: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8577&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8577&lt;&#x2F;a&gt;
  &lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3&gt;Optimizations&lt;&#x2F;h3&gt;
&lt;p&gt;There&#x27;re significant performance improvements for classic fixtures with HABTM data, due to some slightly clever caching model classes, and instantiating fixtures from the model class, instead of expensive constant lookups from the name of the class.&lt;&#x2F;p&gt;
&lt;p&gt;Related changesets: &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8560&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8560&lt;&#x2F;a&gt; and &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8561&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8561&lt;&#x2F;a&gt;&lt;&#x2F;p&gt;
</content>
  </entry>
  <entry>
    <title>Living on the Edge (of Rails) - 1st week of the year edition</title>
    <published>2008-01-09T22:18:20+00:00</published>
    <updated>2008-01-09T22:18:20+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/01/09/living-on-the-edge-of-rails-1st-week-of-the-year-edition/"/>
    <id>https://chuyeow.wtf/2008/01/09/living-on-the-edge-of-rails-1st-week-of-the-year-edition/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/01/09/living-on-the-edge-of-rails-1st-week-of-the-year-edition/">&lt;p&gt;Yup, it&#x27;s time for your weekly dose of the changes on edge Rails, more or less covered in the latest &lt;a href=&quot;http:&#x2F;&#x2F;www.railsenvy.com&#x2F;2008&#x2F;1&#x2F;9&#x2F;rails-envy-podcast-episode-013-1-9-2008&quot;&gt;Rails Envy podcast&lt;&#x2F;a&gt;. Using edge Rails is neither arcane nor terrifying, and hopefully weekly reports like these will allow you to &lt;a href=&quot;http:&#x2F;&#x2F;www.loudthinking.com&#x2F;posts&#x2F;20-dont-overestimate-the-power-of-versions&quot;&gt;take control of your own release schedule&lt;&#x2F;a&gt; with your Rails apps.&lt;&#x2F;p&gt;
&lt;p&gt;This week&#x27;s report covers changes from 31 Dec 2007 to the day the podcast was recorded (6 Jan 2007).&lt;&#x2F;p&gt;
&lt;h3&gt;Caching changes&lt;&#x2F;h3&gt;
&lt;p&gt;Looks like most of the changes from the &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;browser&#x2F;branches&#x2F;2-1-caching&quot;&gt;2.1 caching branch&lt;&#x2F;a&gt; have been&lt;br &#x2F;&gt;
&lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8546&quot;&gt;merged into the trunk&lt;&#x2F;a&gt;. Some key points:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;memcache-client has been &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;browser&#x2F;trunk&#x2F;activesupport&#x2F;lib&#x2F;active_support&#x2F;vendor&#x2F;memcache-client-1.5.0&quot;&gt;vendored&lt;&#x2F;a&gt; (included in Rails directly). MemCacheStore works out of the box in Rails now, no need to install the &lt;a href=&quot;http:&#x2F;&#x2F;dev.robotcoop.com&#x2F;Libraries&#x2F;memcache-client&#x2F;&quot;&gt;memcache-client gem&lt;&#x2F;a&gt;!&lt;&#x2F;li&gt;
&lt;li&gt;The caching code has been refactored and moved into ActiveSupport (&lt;code&gt;ActiveSupport::Cache::*&lt;&#x2F;code&gt;).&lt;&#x2F;li&gt;
&lt;li&gt;Added &lt;code&gt;ActiveRecord::Base.cache_key&lt;&#x2F;code&gt; to make it easier to cache Active Records in combination with the ActiveSupport cache libraries introduced in this changeset.&lt;&#x2F;li&gt;
&lt;li&gt;Fragment cache keys are now by default prefixed with &#x27;views&#x2F;&#x27;.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;em&gt;Deprecation&lt;&#x2F;em&gt;: &lt;code&gt;ActionController::Base.fragment_cache_store&lt;&#x2F;code&gt; is now &lt;code&gt;ActionController::Base.cache_store&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h3&gt;Fragment caching now works in RJS and Builder templates&lt;&#x2F;h3&gt;
&lt;p&gt;Yup, you couldn&#x27;t do fragment caching in non-erb views before - &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8542&quot;&gt;now you can&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3&gt;Freezing Rails now automatically updates your Rails app&lt;&#x2F;h3&gt;
&lt;p&gt;If you&#x27;re using edge Rails and use the &lt;code&gt;rails:freeze:edge&lt;&#x2F;code&gt; rake task, you probably usually forget to run (or maybe you&#x27;re not even aware of) &lt;code&gt;rake rails:update&lt;&#x2F;code&gt; to update your Rails app with the latest config&#x2F;, scripts&#x2F; and javascript files from the version of Rails you just froze to. On edge Rails, the &lt;code&gt;rake rails:freeze:edge&lt;&#x2F;code&gt; task runs the &lt;code&gt;rails:update&lt;&#x2F;code&gt; task for you. +1 for convenience!&lt;&#x2F;p&gt;
&lt;p&gt;I prefer to use &lt;a href=&quot;http:&#x2F;&#x2F;piston.rubyforge.org&#x2F;&quot;&gt;Piston&lt;&#x2F;a&gt; so I&#x27;m gonna have to keep remembering to run my &lt;code&gt;rake rails:update&lt;&#x2F;code&gt; now and then!&lt;&#x2F;p&gt;
&lt;p&gt;Check out the &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8532&quot;&gt;related changeset&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h3&gt;Optimizations&lt;&#x2F;h3&gt;
&lt;p&gt;Only 1 optimization in the past week worth talking about: the &lt;code&gt;ActiveRecord::Base#exists?&lt;&#x2F;code&gt; method is faster. It now uses &lt;code&gt;ActiveRecord::Base#select_all&lt;&#x2F;code&gt; instead of a more expensive &lt;code&gt;ActiveRecord::Base#find&lt;&#x2F;code&gt; that unnecessarily instantiates AR objects. (Check out the &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8531&quot;&gt;related changeset&lt;&#x2F;a&gt;.)&lt;&#x2F;p&gt;
&lt;h3&gt;Bug fixes&lt;&#x2F;h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8541&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8541&lt;&#x2F;a&gt; - Fixed a nasty bug when trying to render partials with layout when done from within the site layout. Yes, you can have &lt;a href=&quot;http:&#x2F;&#x2F;ryandaigle.com&#x2F;articles&#x2F;2007&#x2F;8&#x2F;3&#x2F;what-s-new-in-edge-rails-partials-get-layouts&quot;&gt;layouts for your partials in Rails 2&lt;&#x2F;a&gt;, and yes, you can run into a bug when trying to use partial layouts in your main page layout.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8529&quot;&gt;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8529&lt;&#x2F;a&gt; - Fix &lt;code&gt;atom_feed_helper&lt;&#x2F;code&gt; to comply with the &lt;a href=&quot;http:&#x2F;&#x2F;atomenabled.org&#x2F;developers&#x2F;syndication&#x2F;atom-format-spec.php&quot;&gt;Atom specifications&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
  </entry>
  <entry>
    <title>Living on the Edge (of Rails) - the pilot</title>
    <published>2008-01-02T19:30:57+00:00</published>
    <updated>2008-01-02T19:30:57+00:00</updated>
    <author><name>Chu Yeow</name></author>
    <link rel="alternate" type="text/html" href="https://chuyeow.wtf/2008/01/02/whats-new-on-edge-rails-the-pilot/"/>
    <id>https://chuyeow.wtf/2008/01/02/whats-new-on-edge-rails-the-pilot/</id>
    <content type="html" xml:base="https://chuyeow.wtf/2008/01/02/whats-new-on-edge-rails-the-pilot/">&lt;p&gt;Gregg Pollack of &lt;a href=&quot;http:&#x2F;&#x2F;www.railsenvy.com&#x2F;&quot;&gt;Rails Envy&lt;&#x2F;a&gt; (the guys behind your favorite &lt;a href=&quot;http:&#x2F;&#x2F;www.railsenvy.com&#x2F;tags&#x2F;Commercials&quot;&gt;Ruby on Rails vs everything commercials&lt;&#x2F;a&gt;) asked me recently whether I could provide them with weekly updates of changes on edge Rails for the &lt;a href=&quot;http:&#x2F;&#x2F;www.railsenvy.com&#x2F;podcast&quot;&gt;Rails Envy Podcast&lt;&#x2F;a&gt; (which is often hilarious besides being informative), seeing as I am already keeping up with developments on the Rails trunk while doing my small part contributing to Rails. Of course, I responded with a +1.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;a href=&quot;http:&#x2F;&#x2F;www.railsenvy.com&#x2F;2008&#x2F;1&#x2F;2&#x2F;rails-envy-podcast-episode-012-1-2-2008&quot;&gt;The podcast is now available&lt;&#x2F;a&gt; and contains only abbreviated notes about the changes that I&#x27;d sent over to Gregg, so here&#x27;s the detailed version of changes on edge Rails from the release of Rails 2.0.2 (17 Dec 2007) to the day the podcast was recorded (30 Dec 2007).&lt;&#x2F;p&gt;
&lt;h3&gt;Noteworthy changes on edge Rails: 2007-12-17 to 2007-12-30&lt;&#x2F;h3&gt;
&lt;h4&gt;Native mongrel handler&lt;&#x2F;h4&gt;
&lt;p&gt;A native Mongrel handler has been &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8488&quot;&gt;introduced&lt;&#x2F;a&gt;. This is so that it can be worked on independent of &lt;a href=&quot;http:&#x2F;&#x2F;mongrel.rubyforge.org&#x2F;&quot;&gt;Mongrel&lt;&#x2F;a&gt;&#x27;s release cycle (the Rails handler is currently in the Mongrel codebase). &lt;a href=&quot;bitsweat.net&#x2F;&quot;&gt;Jeremy Kemper&lt;&#x2F;a&gt; (bitsweat) has already made a minor performance improvement by moving the mutex from the handler itself into the dispatcher. This means that as Rails gets more threadsafe, the Rails team can push the mutex further down so that it&#x27;s not a (scary) giant lock (the existing Mongrel Rails handler has a synchronized block around Rails&#x27; dispatcher).&lt;&#x2F;p&gt;
&lt;p&gt;Note: The native mongrel handler is not used by default at this time on edge Rails.&lt;&#x2F;p&gt;
&lt;h4&gt;Caching branch for Rails 2.1&lt;&#x2F;h4&gt;
&lt;p&gt;A &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;log&#x2F;branches&#x2F;2-1-caching&quot;&gt;caching branch&lt;&#x2F;a&gt; has been introduced, targeted for Rails 2.1. Other than being a big refactoring, there&#x27;s also native cache key management (e.g. &lt;code&gt;Product.find(5).cache_key # =&gt; &quot;products&#x2F;5&quot;&lt;&#x2F;code&gt;) and memcache integration is also being looked at.&lt;&#x2F;p&gt;
&lt;h4&gt;Ruby 1.9 compatibility continues...&lt;&#x2F;h4&gt;
&lt;p&gt;Yup, work on Ruby 1.9 compatibility for Rails continues. Rails is fortunate to have committers and contributors who are so keen on being 1.9-compatible - free performance gains are hard to turn down after all. There&#x27;s been lots of patching going on to deal with the changes in Ruby 1.9 (Unicode changes, new syntax, deprecations, etc.).&lt;&#x2F;p&gt;
&lt;p&gt;Yes, the Rails committers and contributors working on 1.9-compatibility are fully aware that Ruby 1.9 is a &lt;strong&gt;development&lt;&#x2F;strong&gt; release, but nothing&#x27;s lost in making sure Rails is compatible with a version of Ruby that will eventually be a production version of Ruby. Besides, I think most of the 1.9-compatibility contributors have a dream that sometime soon, when Ruby 1.9 becomes &quot;stable&quot; enough, we&#x27;d be running our Rails applications on Ruby 1.9 for a free performance boost.&lt;&#x2F;p&gt;
&lt;p&gt;Too bad running Rails on Ruby 1.9 is not really possible at the moment since other projects like Mongrel need to be updated for Ruby 1.9 as well, first.&lt;&#x2F;p&gt;
&lt;h4&gt;Bugfixes&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;a href=&quot;https:&#x2F;&#x2F;chuyeow.wtf&#x2F;2007&#x2F;12&#x2F;27&#x2F;dry-in-your-functional-and-actionmailer-tests-rails-20-a-feature-a-day-7&#x2F;&quot;&gt;new TestCase subclasses&lt;&#x2F;a&gt; (&lt;code&gt;ActionController::TestCase&lt;&#x2F;code&gt;,&lt;br &#x2F;&gt;
  &lt;code&gt;ActionMailer::TestCase&lt;&#x2F;code&gt;) introduced in Rails 2 have a &lt;a href=&quot;http:&#x2F;&#x2F;quotedprintable.com&#x2F;2007&#x2F;12&#x2F;5&#x2F;potential-gotcha-with-test-setup-in-rails-2-0&quot;&gt;gotcha&lt;&#x2F;a&gt;. This has been &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8497&quot;&gt;fixed&lt;&#x2F;a&gt; quickly by &lt;a href=&quot;http:&#x2F;&#x2F;joshpeek.com&#x2F;&quot;&gt;Josh Peek&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;Fixed a bug where trying to :include for a belongs_to association inferred the foreign key incorrectly from the class name, rather than from the association name (&lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8456&quot;&gt;changeset&lt;&#x2F;a&gt; contributed by &lt;a href=&quot;http:&#x2F;&#x2F;www.workingwithrails.com&#x2F;person&#x2F;4985-jonathan-viney&quot;&gt;Jonathan Viney&lt;&#x2F;a&gt;). Code is probably easier to understand:
&lt;pre&gt;&lt;code class=&quot;ruby&quot;&gt;class Post &amp;lt; ActiveRecord::Base
  belongs_to :main_category, :class_name =&amp;gt; &#x27;Category&#x27;
end
&lt;p&gt;Post.find(:first, :include =&amp;gt; :main_category)&lt;&#x2F;p&gt;
&lt;h1 id=&quot;activerecord-statementinvalid-mysql-error-unknown-column&quot;&gt;=&amp;gt; ActiveRecord::StatementInvalid: Mysql::Error: Unknown column&lt;&#x2F;h1&gt;
&lt;p&gt;&#x27;posts.category&#x27; in &#x27;on clause&#x27;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h4&gt;Optimizations&lt;&#x2F;h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8505&quot;&gt;JSON decoding is faster&lt;&#x2F;a&gt;. This helps if you&#x27;re doing a lot of JSON decoding or deserialization (such as via &lt;a href=&quot;http:&#x2F;&#x2F;api.rubyonrails.org&#x2F;classes&#x2F;ActiveRecord&#x2F;Serialization.html#M001136&quot;&gt;&lt;code&gt;ActiveRecord::Base#from_json&lt;&#x2F;code&gt;&lt;&#x2F;a&gt;), or you are using the &lt;a href=&quot;http:&#x2F;&#x2F;api.rubyonrails.org&#x2F;classes&#x2F;ActiveResource&#x2F;Base.html#M000827&quot;&gt;JSON format for ActiveResource&lt;&#x2F;a&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;has_many&lt;&#x2F;code&gt; associations are &lt;a href=&quot;http:&#x2F;&#x2F;dev.rubyonrails.org&#x2F;changeset&#x2F;8504&quot;&gt;no longer loaded unnecessarily&lt;&#x2F;a&gt; in &lt;code&gt;after_update&lt;&#x2F;code&gt; callbacks.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h3&gt;I can has feedback nao plz?&lt;&#x2F;h3&gt;
&lt;p&gt;Please leave any suggestions for improvements you may have - about anything really: format, level of detail, what you&#x27;d like to see, whatever. Until next week...&lt;&#x2F;p&gt;
</content>
  </entry>
</feed>
