<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:arydjmal.com,2005:/posts</id>
  <link rel="alternate" type="text/html" href="http://arydjmal.com"/>
  <link rel="self" type="application/atom+xml" href="http://arydjmal.com/posts.atom"/>
  <title>Ary Djmal's Blog</title>
  <updated>2011-03-14T19:07:24Z</updated>
  <entry>
    <id>tag:arydjmal.com,2005:Post/16</id>
    <published>2011-03-13T16:03:00Z</published>
    <updated>2011-03-15T03:02:52Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2011/3/13/bypass-activerecord-when-using-big-sets-for-fast-response-times"/>
    <title>Bypass ActiveRecord When Using Big Sets For Fast Response Times in Rails 3 &amp; Ruby 1.9.2</title>
    <content type="html">&lt;p&gt;If you need to work with big sets (in my case 1,000 records) ActiveRecord is slow. And so is calling to_json to that collection.&lt;/p&gt;
&lt;p&gt;This is my workaround to transform a ~3000ms request into ~300ms:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# before&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# @users = User.where('some condition').sort('some order')&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# render :json =&amp;gt; @users&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;# after&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt; = &lt;span class=&quot;co&quot;&gt;ActiveRecord&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Base&lt;/span&gt;.connection.select_all(&lt;span class=&quot;co&quot;&gt;User&lt;/span&gt;.where(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;some condition&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).sort(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;some order&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).to_sql)&lt;tt&gt;
&lt;/tt&gt;  render &lt;span class=&quot;sy&quot;&gt;:text&lt;/span&gt; =&amp;gt; &lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Also, in your front-end you need to transform the response into valid json (I&amp;#8217;m usign jQuery):&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;pd&quot;&gt;$&lt;/span&gt;.get(&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/users&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;kw&quot;&gt;function&lt;/span&gt;(users) {&lt;tt&gt;
&lt;/tt&gt;  users = jQuery.parseJSON(users.replace(&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mod&quot;&gt;g&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;).replace(&lt;span class=&quot;rx&quot;&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;nil&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;/&lt;/span&gt;&lt;span class=&quot;mod&quot;&gt;g&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;));&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;c&quot;&gt;// Do the rest&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;});&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;NOTE&lt;/span&gt;: I understand that this is not suitable for most cases, like for a public &lt;span class=&quot;caps&quot;&gt;API&lt;/span&gt;, given that the output is not valid &lt;span class=&quot;caps&quot;&gt;JSON&lt;/span&gt;. Also it has a lot of limitations, like it wont deserialize your serialized_attributes, you cannot use the to_json options like, :methods, :include, etc.&lt;/p&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/15</id>
    <published>2010-08-13T10:05:00Z</published>
    <updated>2010-08-13T15:03:55Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2010/8/13/cocos2d-tip-opacity-ccfadeout-ccfadeto"/>
    <title>cocos2d Tip: Opacity, CCFadeOut, &amp; CCFadeTo</title>
    <content type="html">&lt;p&gt;When using opacity and want to fade out, use fade to!&lt;/p&gt;
&lt;p&gt;Using fade out it will reset the opacity and then fade it out&amp;#8230; so a fade to opacity 0, will prevent the reset.&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;c&quot;&gt;// GIVEN&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;CCSprite *sprite = [CCSprite &lt;span class=&quot;la&quot;&gt;spriteWithFile:&lt;/span&gt;&lt;span class=&quot;er&quot;&gt;@&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;sprite&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;];&lt;tt&gt;
&lt;/tt&gt;sprite.opacity = &lt;span class=&quot;i&quot;&gt;150&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;c&quot;&gt;// DO&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;[sprite &lt;span class=&quot;la&quot;&gt;runAction:&lt;/span&gt;[CCFadeTo &lt;span class=&quot;la&quot;&gt;actionWithDuration:&lt;/span&gt;&lt;span class=&quot;fl&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;fl&quot;&gt;.0f&lt;/span&gt; &lt;span class=&quot;la&quot;&gt;opacity:&lt;/span&gt;&lt;span class=&quot;i&quot;&gt;0&lt;/span&gt;]];&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;c&quot;&gt;// DON'T&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;[sprite &lt;span class=&quot;la&quot;&gt;runAction:&lt;/span&gt;[CCFadeOut &lt;span class=&quot;la&quot;&gt;actionWithDuration:&lt;/span&gt;&lt;span class=&quot;fl&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;fl&quot;&gt;.0f&lt;/span&gt;]];&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/14</id>
    <published>2010-08-12T11:46:00Z</published>
    <updated>2010-08-16T18:17:11Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2010/8/12/cocos2d-layer-that-swallows-touches"/>
    <title>cocos2d: Layer That Swallows Touches</title>
    <content type="html">&lt;p&gt;So you want to add a layer with a few buttons and you don&amp;#8217;t want to propagate the touches to the layers below.&lt;/p&gt;
&lt;p&gt;Easy, just stick the following in your layer to enable &amp;#8220;swallow touches&amp;#8221;.&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;- (&lt;span class=&quot;pt&quot;&gt;void&lt;/span&gt;)onEnter {&lt;tt&gt;
&lt;/tt&gt;  [[CCTouchDispatcher sharedDispatcher] &lt;span class=&quot;la&quot;&gt;addTargetedDelegate:&lt;/span&gt;self &lt;span class=&quot;la&quot;&gt;priority:&lt;/span&gt;INT_MIN+&lt;span class=&quot;i&quot;&gt;1&lt;/span&gt; &lt;span class=&quot;la&quot;&gt;swallowsTouches:&lt;/span&gt;YES];&lt;tt&gt;
&lt;/tt&gt;  [super onEnter];&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;- (&lt;span class=&quot;pt&quot;&gt;void&lt;/span&gt;)onExit {&lt;tt&gt;
&lt;/tt&gt;  [[CCTouchDispatcher sharedDispatcher] &lt;span class=&quot;la&quot;&gt;removeDelegate:&lt;/span&gt;self];&lt;tt&gt;
&lt;/tt&gt;  [super onExit];&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;- (BOOL)&lt;span class=&quot;la&quot;&gt;ccTouchBegan:&lt;/span&gt;(UITouch *)touch &lt;span class=&quot;la&quot;&gt;withEvent:&lt;/span&gt;(UIEvent *)event {&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;return&lt;/span&gt; YES;&lt;tt&gt;
&lt;/tt&gt;}&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/13</id>
    <published>2010-01-06T00:00:00Z</published>
    <updated>2010-01-12T02:50:17Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2010/1/6/cache-single-activerecord-objects-with-model_cached"/>
    <title>Cache Single ActiveRecord Objects with model_cached!</title>
    <content type="html">&lt;p&gt;I&amp;#8217;ve just released a very simple Rails plugin that gives you the ability to transparently cache single active record objects using memcached.&lt;/p&gt;
&lt;p&gt;The purpose is to cache by fields that are being validated for unique values.&lt;/p&gt;
&lt;p&gt;Cache gets refresh after save, and expire after destroy or after a logical delete.&lt;/p&gt;
&lt;p&gt;It is less than 100 lines of code, so don&#8217;t be shy to look at the source for full understanding.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://github.com/arydjmal/model_cached&quot;&gt;http://github.com/arydjmal/model_cached&lt;/a&gt;&lt;/p&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/12</id>
    <published>2009-01-11T00:00:00Z</published>
    <updated>2011-03-15T02:49:22Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2009/1/11/to_xls-plugin-export-to-excel-in-rails-the-easy-way"/>
    <title>to_xls Plugin: Export to Excel in Rails the Easy Way</title>
    <content type="html">&lt;p&gt;Looking at the Google Analytics stats I realized that a lot of people are still reading my blog post about &lt;a href=&quot;http://arydjmal.com/2008/6/8/export-to-excel-in-rails-2&quot;&gt;how to export to Excel in Rails&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;IMO&lt;/span&gt; I prefer the &lt;a href=&quot;http://arydjmal.com/2008/6/11/to_csv-plugin-better-excel-compatibility&quot;&gt;csv method&lt;/a&gt; because it provides the same + more at no extra cost, but given people still wants xls files I wrote another rails plugin: to_xls.&lt;/p&gt;
&lt;hr/&gt;
&lt;h2&gt;&lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt;: SuperSaaS (Thanks!) mentioned that Excel does not interpret UTF8 characters in &lt;span class=&quot;caps&quot;&gt;CSV&lt;/span&gt; files. So if that is a concern to you, maybe you should stick with &lt;span class=&quot;caps&quot;&gt;XLS&lt;/span&gt;.&lt;/h2&gt;
&lt;hr/&gt;
&lt;p&gt;Using this plugin you don&amp;#8217;t need the builder views, so it makes it as easy as the to_csv plugin I wrote. In fact it works the same.&lt;/p&gt;
&lt;p&gt;In config/initializers/mime_types.rb register the custom mime type.&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;co&quot;&gt;Mime&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Type&lt;/span&gt;.register &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;application/vnd.ms-excel&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:xls&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;In the controller where you want to export to excel, add the format.xls line.&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;UserController&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt; = &lt;span class=&quot;co&quot;&gt;User&lt;/span&gt;.all&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    respond_to &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |format|&lt;tt&gt;
&lt;/tt&gt;      format.html&lt;tt&gt;
&lt;/tt&gt;      format.xml { render &lt;span class=&quot;sy&quot;&gt;:xml&lt;/span&gt; =&amp;gt; &lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;      format.xls { send_data &lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt;.to_xls }&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;That&amp;#8217;s it!&lt;/p&gt;
&lt;h2&gt;Install&lt;/h2&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;./script/plugin install git&lt;span class=&quot;sy&quot;&gt;:/&lt;/span&gt;/github.com/arydjmal/to_xls.git&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/11</id>
    <published>2008-08-26T00:00:00Z</published>
    <updated>2010-01-12T02:48:59Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2008/8/26/textareamate-turns-your-textarea-s-into-simple-code-editors"/>
    <title>TextAreaMate turns your textarea's into simple code editors</title>
    <content type="html">&lt;p&gt;TextAreaMate is a simple javascript library on top of Prototype, that turns a textarea into a simple code editor with a TextMate feeling.&lt;/p&gt;
&lt;p&gt;For now it&#8217;s working on FF &amp;amp; Safari, Mac only. As soon as I get it to work cross-browser I will put it on GitHub for further development.&lt;/p&gt;
&lt;h2&gt;Features&lt;/h2&gt;
&lt;p&gt;tab key support&lt;br /&gt;
command + / for commenting lines&lt;br /&gt;
command + [ for indenting less (one line or a block of code).&lt;br /&gt;
command + ] for indenting more (one line or a block of code).&lt;br /&gt;
Dependencies&lt;/p&gt;
&lt;p&gt;Prototype JavaScipt Library&lt;/p&gt;
&lt;h2&gt;Install&lt;/h2&gt;
&lt;p&gt;Get the beta &lt;a href=&quot;http://arydjmal.com/javascripts/textareamate.js&quot;&gt;here&lt;/a&gt; and copy both files to the appropriate directory.&lt;/p&gt;
&lt;h2&gt;Usage&lt;/h2&gt;
&lt;p&gt;Include prototype.js and textareamate.js:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;prototype.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;charset&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;utf-8&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;script&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;textareamate.js&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;type&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;text/javascript&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;charset&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;utf-8&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;For railers, something like:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;&amp;lt;%=&lt;/span&gt; javascript_include_tag &lt;span class=&quot;sy&quot;&gt;:defaults&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;textareamate&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;idl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Now you can start using it:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;textarea&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;name&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;editor&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;id&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;editor&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;onkeydown&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;return TextAreaMate.onKeyPress(this,event)&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/textarea&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;It plays well with rails:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;&amp;lt;%=&lt;/span&gt; text_area &lt;span class=&quot;sy&quot;&gt;:pastie&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:body&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:onkeydown&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;return TextAreaMate.onKeyPress(this,event)&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;  &lt;span class=&quot;idl&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;h2&gt;Demo&lt;/h2&gt;
&lt;textarea id=&quot;post_body&quot; onkeydown=&quot;return TextAreaMate.onKeyPress(this,event)&quot;&gt;
class AddOn &amp;lt; ActiveRecord::Base
  belongs_to :project  
  belongs_to :unit

  validates_presence_of :name, :add_on_type, :project

  def available?
    unit.nil?
  end

  def reserved?
    unit &amp;#38;&amp;#38; !unit.sold?
  end

  def sold?
    unit &amp;#38;&amp;#38; unit.sold?
  end
end
&lt;/textarea&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/10</id>
    <published>2008-08-12T00:00:00Z</published>
    <updated>2010-01-12T02:48:18Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2008/8/12/css-tip-three-state-buttons"/>
    <title>CSS Tip: Three-State Buttons</title>
    <content type="html">&lt;p&gt;Let&#8217;s say you have a text button that highlights when you hovered. You can add a third state, when clicked, by specifying a:active the same way you use a:hover. No javascript needed.&lt;/p&gt;
&lt;p&gt;In your html:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;href&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;button&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  Some Text&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;In your css:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;kw&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;cl&quot;&gt;.button&lt;/span&gt;&lt;span class=&quot;ps&quot;&gt;:link&lt;/span&gt;, &lt;span class=&quot;kw&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;cl&quot;&gt;.button&lt;/span&gt;&lt;span class=&quot;ps&quot;&gt;:visited&lt;/span&gt;, &lt;span class=&quot;kw&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;cl&quot;&gt;.button&lt;/span&gt;&lt;span class=&quot;ps&quot;&gt;:hover&lt;/span&gt; {&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;padding&lt;/span&gt;: &lt;span class=&quot;fl&quot;&gt;15px&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;text-decoration&lt;/span&gt;: &lt;span class=&quot;vl&quot;&gt;none&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;color&lt;/span&gt;: &lt;span class=&quot;cr&quot;&gt;#666&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;display&lt;/span&gt;:&lt;span class=&quot;vl&quot;&gt;block&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;border-bottom&lt;/span&gt;: &lt;span class=&quot;fl&quot;&gt;1px&lt;/span&gt; &lt;span class=&quot;vl&quot;&gt;solid&lt;/span&gt; &lt;span class=&quot;cr&quot;&gt;#CCC&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;font-size&lt;/span&gt;: &lt;span class=&quot;fl&quot;&gt;12px&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;cl&quot;&gt;.button&lt;/span&gt;&lt;span class=&quot;ps&quot;&gt;:hover&lt;/span&gt; {&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;background-color&lt;/span&gt;: &lt;span class=&quot;cr&quot;&gt;#F9F9F9&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;cl&quot;&gt;.button&lt;/span&gt;&lt;span class=&quot;ps&quot;&gt;:active&lt;/span&gt; {&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;background-color&lt;/span&gt;: &lt;span class=&quot;cr&quot;&gt;#FFF&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;color&lt;/span&gt;: &lt;span class=&quot;cr&quot;&gt;#333&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;h2&gt;Demo&lt;/h2&gt;
&lt;div class=&quot;buttons&quot;&gt;
&lt;a href=&quot;http://workingwithrails.com/recommendation/new/person/12850-ary-djmal&quot; class=&quot;button&quot;&gt;Recommend Me&lt;/a&gt;
&lt;/div&gt;

&lt;style&gt;
div.buttons {
  border-top: 1px solid #CCC;
  margin-bottom:10px;
  background: #EEE;
  width: 300px;
}
a.button:link, a.button:visited, a.button:hover {
  padding: 15px;
  text-decoration: none;
  color: #666;
  display:block;
  border-bottom: 1px solid #CCC;
  font-size: 12px;
}
a.button:hover {
  background-color: #F9F9F9;
}
a.button:active {
  background-color: #FFF;
  color: #333;
}
&lt;/style&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/9</id>
    <published>2008-08-05T00:00:00Z</published>
    <updated>2010-01-12T02:47:40Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2008/8/5/css-tip-two-state-images"/>
    <title>CSS Tip: Two-State Images</title>
    <content type="html">&lt;p&gt;Let&#8217;s say you have an image that when you hovered you want to highlight (ie. make it brighter). Instead of dealing with two different images you can just use opacity.&lt;/p&gt;
&lt;p&gt;In your html:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;a&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;href&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;#&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;class&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;ta&quot;&gt;&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ta&quot;&gt;&amp;lt;img&lt;/span&gt; &lt;span class=&quot;an&quot;&gt;src&lt;/span&gt;=&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;/some_image.jpg&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;ta&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;ta&quot;&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;In your css:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;kw&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;cl&quot;&gt;.image&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;img&lt;/span&gt; {&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;opacity&lt;/span&gt;: &lt;span class=&quot;fl&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;fl&quot;&gt;.60&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;-moz-opacity&lt;/span&gt;: &lt;span class=&quot;fl&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;fl&quot;&gt;.60&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;filter&lt;/span&gt;:&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;alpha(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;opacity=60&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;)&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;kw&quot;&gt;a&lt;/span&gt;&lt;span class=&quot;cl&quot;&gt;.image&lt;/span&gt;&lt;span class=&quot;ps&quot;&gt;:hover&lt;/span&gt; &lt;span class=&quot;kw&quot;&gt;img&lt;/span&gt; {&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;opacity&lt;/span&gt;: &lt;span class=&quot;fl&quot;&gt;1&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;-moz-opacity&lt;/span&gt;: &lt;span class=&quot;fl&quot;&gt;1&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;ke&quot;&gt;filter&lt;/span&gt;:&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;alpha(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;opacity=100&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;)&lt;/span&gt;&lt;/span&gt;;&lt;tt&gt;
&lt;/tt&gt;}&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;h2&gt;Demo&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;http://workingwithrails.com/recommendation/new/person/12850-ary-djmal&quot; class=&quot;image&quot;&gt;&lt;img alt=&quot;Recommend Me&quot; src=&quot;http://workingwithrails.com/images/tools/compact-small-button.jpg&quot; /&gt;&lt;/a&gt;&lt;/p&gt;


&lt;style&gt;
a.image img {
  opacity: 0.60;
  -moz-opacity: 0.60;
  filter:alpha(opacity=60);
}

a.image:hover img {
  opacity: 1;
  -moz-opacity: 1;
  filter:alpha(opacity=100);
}
&lt;/style&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/8</id>
    <published>2008-07-22T00:00:00Z</published>
    <updated>2010-01-12T02:47:05Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2008/7/22/in_place_editing-plugin-with-validations"/>
    <title>in_place_editing Plugin with validations!</title>
    <content type="html">&lt;p&gt;I forked the in_place_editing plugin from Github and modified it so it validates your model before saving.&lt;/p&gt;
&lt;p&gt;If you are interested, &lt;a href=&quot;http://github.com/arydjmal/in_place_editing/tree/master&quot;&gt;check it out&lt;/a&gt;.&lt;/p&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/7</id>
    <published>2008-06-11T00:00:00Z</published>
    <updated>2011-03-15T03:04:37Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2008/6/11/to_csv-plugin-better-excel-compatibility"/>
    <title>to_csv plugin: Better Excel Compatibility</title>
    <content type="html">&lt;p&gt;A couple of days ago I blogged about how to export to MS Excel. I took an example from a client&#8217;s app, in which they are the final-users, and I know for sure they only use Excel 2003.&lt;/p&gt;
&lt;p&gt;But if your app needs some sort of export feature, and you don&#8217;t know how the users are going to use the data, I would go with &lt;span class=&quot;caps&quot;&gt;CSV&lt;/span&gt;. Why? As far as I know every spreadsheet app can open it, including Numbers and Office 2000 (which don&#8217;t handle &lt;span class=&quot;caps&quot;&gt;XML&lt;/span&gt;-based xls files), plus they might use it with report tools unrelated to excel. And as a bonus it is much easier to use.&lt;/p&gt;
&lt;h2&gt;The Solution&lt;/h2&gt;
&lt;p&gt;Last night I wrote a very simple plugin called to_csv that gives you the ability to call to_csv to a collection of activerecords. The builder options are the same as to_json / to_xml, except for the :include.&lt;/p&gt;
&lt;h2&gt;Usage&lt;/h2&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt; = &lt;span class=&quot;co&quot;&gt;User&lt;/span&gt;.all&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;c&quot;&gt;# defaults are export header and all fields except id, and timestamps&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;c&quot;&gt;#&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt;.to_csv&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt;.to_csv(&lt;span class=&quot;sy&quot;&gt;:only&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;sy&quot;&gt;:last_name&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:role&lt;/span&gt;])&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt;.to_csv(&lt;span class=&quot;sy&quot;&gt;:timestamps&lt;/span&gt; =&amp;gt; &lt;span class=&quot;pc&quot;&gt;true&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:id&lt;/span&gt; =&amp;gt; &lt;span class=&quot;pc&quot;&gt;true&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:header&lt;/span&gt; =&amp;gt; &lt;span class=&quot;pc&quot;&gt;false&lt;/span&gt;)&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt;.to_csv(&lt;span class=&quot;sy&quot;&gt;:except&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;sy&quot;&gt;:last_name&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:role&lt;/span&gt;])&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt;.to_csv(&lt;span class=&quot;sy&quot;&gt;:except&lt;/span&gt; =&amp;gt; &lt;span class=&quot;sy&quot;&gt;:role&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:methods&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;sy&quot;&gt;:name&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:admin?&lt;/span&gt;])&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;h2&gt;Real life example&lt;/h2&gt;
&lt;p&gt;In the controller where you want to export to csv, add the format.csv line (as of rails 2.1 it is not necessary to register the csv myme_type)&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;r&quot;&gt;class&lt;/span&gt; &lt;span class=&quot;cl&quot;&gt;UserController&lt;/span&gt; &amp;lt; &lt;span class=&quot;co&quot;&gt;ApplicationController&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt; = &lt;span class=&quot;co&quot;&gt;User&lt;/span&gt;.all&lt;tt&gt;
&lt;/tt&gt;    respond_to &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |format|&lt;tt&gt;
&lt;/tt&gt;      format.html&lt;tt&gt;
&lt;/tt&gt;      format.xml { render &lt;span class=&quot;sy&quot;&gt;:xml&lt;/span&gt; =&amp;gt; &lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;      format.csv { send_data &lt;span class=&quot;iv&quot;&gt;@users&lt;/span&gt;.to_csv }&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;That&#8217;s it. No myme_type to register, no views to create, just install the plugin, and add format.csv { send_data collection.to_csv } to the controller&#8217;s respond_to block that you want to give export capabilities.&lt;/p&gt;
&lt;h2&gt;Install&lt;/h2&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;./script/plugin install git&lt;span class=&quot;sy&quot;&gt;:/&lt;/span&gt;/github.com/arydjmal/to_csv.git&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;h2&gt;Ideas&lt;/h2&gt;
&lt;p&gt;I got ideas and influence from Mike Clarks recipe#35 in Rails Recipes book, some anonymous pastie, and whoever wrote to_xml/to_json builders.&lt;/p&gt;
&lt;h2&gt;Note&lt;/h2&gt;
&lt;p&gt;Does not work on a single activerecord, ie, User.first.to_csv. Cannot style output like xls.&lt;/p&gt;
&lt;h2&gt;Update&lt;/h2&gt;
&lt;p&gt;I modified the plugin so now it uses the fastercsv library instead of the old &lt;span class=&quot;caps&quot;&gt;CSV&lt;/span&gt; library. SO if you don&#8217;t have the gem installed type:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;sudo gem install fastercsv&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/6</id>
    <published>2008-06-08T00:00:00Z</published>
    <updated>2011-03-15T03:06:23Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2008/6/8/export-to-excel-in-rails-2"/>
    <title>Export to Excel in Rails 2</title>
    <content type="html">&lt;hr/&gt;
&lt;h2&gt;&lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt;: I released a Rails plugin that makes this much easier, &lt;a href=&quot;http://arydjmal.com/2009/1/11/to_xls-plugin-export-to-excel-in-rails-the-easy-way&quot;&gt;http://arydjmal.com/2009/1/11/to_xls-plugin-export-to-excel-in-rails-the-easy-way&lt;/a&gt;.&lt;br /&gt;
&lt;hr/&gt;&lt;/h2&gt;
&lt;p&gt;Rails makes it super-easy to export anything to Excel. I took this example from a client&#8217;s project; they wanted to export to excel the data generated from orders/index.&lt;/p&gt;
&lt;p&gt;I will summarize this in 3 simple steps:&lt;/p&gt;
&lt;p&gt;First, you have to register the mime type in your config/initializers/mime_types.rb. This is needed for the respond_to block in the controller, and of course you have to do it only once.&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;co&quot;&gt;Mime&lt;/span&gt;::&lt;span class=&quot;co&quot;&gt;Type&lt;/span&gt;.register &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;application/vnd.ms-excel&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:xls&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Restart the server so the new configuration is loaded.&lt;/p&gt;
&lt;p&gt;Now we are ready to respond in xls format; in this example http://localhost:3000/orders will render index.html.erb and http://localhost:3000/orders.xls will create a xls. So in the app/controllers/orders_controllers.rb we can have something like this:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;iv&quot;&gt;@orders&lt;/span&gt; = &lt;span class=&quot;co&quot;&gt;Order&lt;/span&gt;.recent&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  respond_to &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |format|&lt;tt&gt;
&lt;/tt&gt;    format.html&lt;tt&gt;
&lt;/tt&gt;    format.xls&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Pretty clean, right? Finally, we need to create the excel file, and since Excel can read xml in the app/views/orders/index.xls.builder we have something like:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;25&lt;tt&gt;
&lt;/tt&gt;26&lt;tt&gt;
&lt;/tt&gt;27&lt;tt&gt;
&lt;/tt&gt;28&lt;tt&gt;
&lt;/tt&gt;29&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;xml.instruct! &lt;span class=&quot;sy&quot;&gt;:xml&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:version&lt;/span&gt;=&amp;gt;&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:encoding&lt;/span&gt;=&amp;gt;&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;UTF-8&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;tt&gt;
&lt;/tt&gt;xml.Workbook({&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;      =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;urn:schemas-microsoft-com:office:spreadsheet&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;xmlns:o&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;    =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;urn:schemas-microsoft-com:office:office&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;xmlns:x&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;    =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;urn:schemas-microsoft-com:office:excel&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,    &lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;xmlns:html&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;http://www.w3.org/TR/REC-html40&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;xmlns:ss&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;   =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;urn:schemas-microsoft-com:office:spreadsheet&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;tt&gt;
&lt;/tt&gt;  }) &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  xml.&lt;span class=&quot;co&quot;&gt;Worksheet&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Recent Orders&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    xml.&lt;span class=&quot;co&quot;&gt;Table&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;c&quot;&gt;# Header&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      xml.&lt;span class=&quot;co&quot;&gt;Row&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Cell&lt;/span&gt; { xml.&lt;span class=&quot;co&quot;&gt;Data&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Cell&lt;/span&gt; { xml.&lt;span class=&quot;co&quot;&gt;Data&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Cell&lt;/span&gt; { xml.&lt;span class=&quot;co&quot;&gt;Data&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;c&quot;&gt;# Rows&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;r&quot;&gt;for&lt;/span&gt; order &lt;span class=&quot;r&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;iv&quot;&gt;@orders&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Row&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;          xml.&lt;span class=&quot;co&quot;&gt;Cell&lt;/span&gt; { xml.&lt;span class=&quot;co&quot;&gt;Data&lt;/span&gt; order.id, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;          xml.&lt;span class=&quot;co&quot;&gt;Cell&lt;/span&gt; { xml.&lt;span class=&quot;co&quot;&gt;Data&lt;/span&gt; order.date, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;          xml.&lt;span class=&quot;co&quot;&gt;Cell&lt;/span&gt; { xml.&lt;span class=&quot;co&quot;&gt;Data&lt;/span&gt; order.description, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;        &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;With this 3 easy steps you can give a export to xls any view.&lt;/p&gt;
&lt;p&gt;So my export to excel link for the view would be:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;link_to &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Export to Excel&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, formatted_orders_url(&lt;span class=&quot;sy&quot;&gt;:xls&lt;/span&gt;)&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Now, the bigger reason I wrote this mini tutorial, was that this set-up gave me some trouble on IE. It was always rendering format.xls so my little-ugly-hack was to make sure that params[:format] is xls&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;index&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;iv&quot;&gt;@orders&lt;/span&gt; = &lt;span class=&quot;co&quot;&gt;Order&lt;/span&gt;.recent&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  respond_to &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |format|&lt;tt&gt;
&lt;/tt&gt;    format.html&lt;tt&gt;
&lt;/tt&gt;    format.xls &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; params[&lt;span class=&quot;sy&quot;&gt;:format&lt;/span&gt;] == &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;xls&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Please, let me know if you have a better way to solve this problem.&lt;/p&gt;
&lt;p&gt;Now, if you plan to have more than one xls view, I suggest to create this helper in app/helpers/application_helper.rb:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;22&lt;tt&gt;
&lt;/tt&gt;23&lt;tt&gt;
&lt;/tt&gt;24&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;excel_document&lt;/span&gt;(xml, &amp;amp;block)&lt;tt&gt;
&lt;/tt&gt;  xml.instruct! &lt;span class=&quot;sy&quot;&gt;:xml&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:version&lt;/span&gt;=&amp;gt;&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;1.0&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:encoding&lt;/span&gt;=&amp;gt;&lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;UTF-8&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;tt&gt;
&lt;/tt&gt;  xml.Workbook({&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;      =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;urn:schemas-microsoft-com:office:spreadsheet&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;, &lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;xmlns:o&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;    =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;urn:schemas-microsoft-com:office:office&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;xmlns:x&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;    =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;urn:schemas-microsoft-com:office:excel&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,    &lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;xmlns:html&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;http://www.w3.org/TR/REC-html40&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;,&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;xmlns:ss&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;   =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;urn:schemas-microsoft-com:office:spreadsheet&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;tt&gt;
&lt;/tt&gt;  }) &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    xml.&lt;span class=&quot;co&quot;&gt;Styles&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      xml.&lt;span class=&quot;co&quot;&gt;Style&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:ID&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Default&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Normal&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Alignment&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Vertical&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Bottom&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Borders&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Font&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:FontName&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Arial&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Interior&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;NumberFormat&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Protection&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;yield&lt;/span&gt; block&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;So now the view would be:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;21&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;excel_document(xml) &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  xml.&lt;span class=&quot;co&quot;&gt;Worksheet&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Name&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Recent Orders&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    xml.&lt;span class=&quot;co&quot;&gt;Table&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;c&quot;&gt;# Header&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      xml.&lt;span class=&quot;co&quot;&gt;Row&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Cell&lt;/span&gt; { xml.&lt;span class=&quot;co&quot;&gt;Data&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ID&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Cell&lt;/span&gt; { xml.&lt;span class=&quot;co&quot;&gt;Data&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Date&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Cell&lt;/span&gt; { xml.&lt;span class=&quot;co&quot;&gt;Data&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Description&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;c&quot;&gt;# Rows&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;r&quot;&gt;for&lt;/span&gt; order &lt;span class=&quot;r&quot;&gt;in&lt;/span&gt; &lt;span class=&quot;iv&quot;&gt;@orders&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;        xml.&lt;span class=&quot;co&quot;&gt;Row&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;          xml.&lt;span class=&quot;co&quot;&gt;Cell&lt;/span&gt; { xml.&lt;span class=&quot;co&quot;&gt;Data&lt;/span&gt; order.id, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Number&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;          xml.&lt;span class=&quot;co&quot;&gt;Cell&lt;/span&gt; { xml.&lt;span class=&quot;co&quot;&gt;Data&lt;/span&gt; order.date, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;          xml.&lt;span class=&quot;co&quot;&gt;Cell&lt;/span&gt; { xml.&lt;span class=&quot;co&quot;&gt;Data&lt;/span&gt; order.description, &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;ss:Type&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;String&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;        &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;NOTE&lt;/span&gt;: This works with Office 2003+ for windows and Office 2004+ for Mac, it will not work with Office 2000, Numbers or QuickLook. So if this is a problem you could try another solution.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt;: Check out my to_csv plugin for better excel compatibility!&lt;/p&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/5</id>
    <published>2008-06-08T00:00:00Z</published>
    <updated>2010-01-12T02:42:18Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2008/6/8/what-i-ve-learned-at-railsconf-08"/>
    <title>What I've learned at RailsConf '08</title>
    <content type="html">&lt;p&gt;1) The value of open source.&lt;/p&gt;
&lt;p&gt;Open source is really amazing. I&#8217;m looking forward to contribute to rails, and to write more plugins/gems. Why? It&#8217;s very probable that &#8220;your plugin (or whatever &lt;span class=&quot;caps&quot;&gt;OSS&lt;/span&gt;)&#8221; it is going get better as more people use it or contribute to it. You will meet people, you&#8217;ll get your name out there, and a job opportunity may arise because of your results.&lt;/p&gt;
&lt;p&gt;2) The value of hooking up with other programmers.&lt;/p&gt;
&lt;p&gt;First it is fun to have friends like you. It&#8217;s also great to have close people to share knowledge, problems, etc. And again you might have job opportunities thanks to these relations.&lt;/p&gt;
&lt;p&gt;3) How we (programmers) should work with designers.&lt;/p&gt;
&lt;p&gt;There were great talks at RailsConf, but I think this is the only session that taught me something. It was great talk given by Ryan Singer of 37Signals, he is a designer, not a programmer. A lot of people misunderstood his talk, and the purpose of it, eventhough Ryan made it pretty clear. In a nutshell:&lt;/p&gt;
&lt;p&gt;(&lt;span class=&quot;caps&quot;&gt;DESIGNER&lt;/span&gt; &amp;#8211; &lt;span class=&quot;caps&quot;&gt;PHOTOSHOP&lt;/span&gt; + &lt;span class=&quot;caps&quot;&gt;HTML&lt;/span&gt;/&lt;span class=&quot;caps&quot;&gt;CSS&lt;/span&gt; + RAILS_SOURCE) + &lt;span class=&quot;caps&quot;&gt;PROGRAMMER&lt;/span&gt; = &lt;span class=&quot;caps&quot;&gt;SUCCESS&lt;/span&gt; &lt;br /&gt;
4) I&#8217;m not alone.&lt;/p&gt;
&lt;p&gt;The rails community is getting bigger and bigger, it was incredible to see so many people at a conference.&lt;/p&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/4</id>
    <published>2008-05-23T00:00:00Z</published>
    <updated>2010-01-12T02:41:43Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2008/5/23/getting-ready-for-my-very-first-railsconf"/>
    <title>Getting ready for my very first RailsConf</title>
    <content type="html">&lt;p&gt;I&#8217;m really excited about this coming RailsConf, I&#8217;m certain that I&#8217;m going to meet a lot of talented people!&lt;/p&gt;
&lt;p&gt;Can&#8217;t wait&#8230;&lt;/p&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/3</id>
    <published>2008-04-10T00:00:00Z</published>
    <updated>2010-01-12T02:39:19Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2008/4/10/link_to_tagged_current"/>
    <title>link_to_tagged_current</title>
    <content type="html">&lt;p&gt;Almost every site has some sort of tabbed navigation. There are a lot of alternatives of how to accomplish it. One way that comes to my mind is Paolo Dona&#8217;s widgets plugin. But sometimes I want something lighter, and link_to_unless_current is way too simple. So I created link_to_tagged_current, a very simple rails helper that in difference of link_to_unless_current, when current, it creates the link + it adds the class current to it.&lt;/p&gt;
&lt;p&gt;In app/helpers/application_helper.rb&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;link_to_tagged_current&lt;/span&gt;(name, options = {}, html_options = {}, &amp;amp;block)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; current_page?(options)&lt;tt&gt;
&lt;/tt&gt;    html_options[&lt;span class=&quot;sy&quot;&gt;:class&lt;/span&gt;] = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;html_options[&lt;span class=&quot;sy&quot;&gt;:class&lt;/span&gt;].to_s&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; current&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;.strip&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  link_to name, options, html_options, &amp;amp;block&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;After little use, this was still pretty simple, so I added a :highlights_on option.&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;4&lt;tt&gt;
&lt;/tt&gt;5&lt;tt&gt;
&lt;/tt&gt;6&lt;tt&gt;
&lt;/tt&gt;7&lt;tt&gt;
&lt;/tt&gt;8&lt;tt&gt;
&lt;/tt&gt;9&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;10&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;11&lt;tt&gt;
&lt;/tt&gt;12&lt;tt&gt;
&lt;/tt&gt;13&lt;tt&gt;
&lt;/tt&gt;14&lt;tt&gt;
&lt;/tt&gt;15&lt;tt&gt;
&lt;/tt&gt;16&lt;tt&gt;
&lt;/tt&gt;17&lt;tt&gt;
&lt;/tt&gt;18&lt;tt&gt;
&lt;/tt&gt;19&lt;tt&gt;
&lt;/tt&gt;&lt;strong&gt;20&lt;/strong&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;link_to_tagged_current&lt;/span&gt;(name, options = {}, html_options = {}, &amp;amp;block)&lt;tt&gt;
&lt;/tt&gt;  current = &lt;span class=&quot;pc&quot;&gt;false&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  highlights = html_options[&lt;span class=&quot;sy&quot;&gt;:highlights_on&lt;/span&gt;] ? html_options[&lt;span class=&quot;sy&quot;&gt;:highlights_on&lt;/span&gt;] + [options] : [options]&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  highlights.each &lt;span class=&quot;r&quot;&gt;do&lt;/span&gt; |h|&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; (h[&lt;span class=&quot;sy&quot;&gt;:controller&lt;/span&gt;] == &lt;span class=&quot;iv&quot;&gt;@controller&lt;/span&gt;.controller_name &lt;span class=&quot;r&quot;&gt;and&lt;/span&gt; !h[&lt;span class=&quot;sy&quot;&gt;:action&lt;/span&gt;]) &lt;span class=&quot;r&quot;&gt;or&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;       (h[&lt;span class=&quot;sy&quot;&gt;:controller&lt;/span&gt;] == &lt;span class=&quot;iv&quot;&gt;@controller&lt;/span&gt;.controller_name &lt;span class=&quot;r&quot;&gt;and&lt;/span&gt; h[&lt;span class=&quot;sy&quot;&gt;:action&lt;/span&gt;] == &lt;span class=&quot;iv&quot;&gt;@controller&lt;/span&gt;.action_name &lt;span class=&quot;r&quot;&gt;and&lt;/span&gt; !h[&lt;span class=&quot;sy&quot;&gt;:id&lt;/span&gt;]) &lt;span class=&quot;r&quot;&gt;or&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;       (!h.kind_of?(&lt;span class=&quot;co&quot;&gt;Hash&lt;/span&gt;) &lt;span class=&quot;r&quot;&gt;and&lt;/span&gt; current_page?(h))&lt;tt&gt;
&lt;/tt&gt;      current = &lt;span class=&quot;pc&quot;&gt;true&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;      &lt;span class=&quot;r&quot;&gt;break&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;    &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; current&lt;tt&gt;
&lt;/tt&gt;    html_options[&lt;span class=&quot;sy&quot;&gt;:class&lt;/span&gt;] = &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;il&quot;&gt;&lt;span class=&quot;idl&quot;&gt;#{&lt;/span&gt;html_options[&lt;span class=&quot;sy&quot;&gt;:class&lt;/span&gt;].to_s&lt;span class=&quot;idl&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt; current&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;.strip&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;&lt;tt&gt;
&lt;/tt&gt;  html_options[&lt;span class=&quot;sy&quot;&gt;:highlights_on&lt;/span&gt;] = &lt;span class=&quot;pc&quot;&gt;nil&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;  link_to name, options, html_options, &amp;amp;block&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Some usage examples are:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;link_to_tagged_current &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Dashboard&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, dashboard_url&lt;tt&gt;
&lt;/tt&gt;link_to_tagged_current &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;Users&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;, users_url, &lt;span class=&quot;sy&quot;&gt;:highlights_on&lt;/span&gt; =&amp;gt; [&lt;span class=&quot;sy&quot;&gt;:controller&lt;/span&gt; =&amp;gt; &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;admin&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;'&lt;/span&gt;&lt;/span&gt;]&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Given this is a very common need I will try to push it to rails.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;caps&quot;&gt;UPDATE&lt;/span&gt;: Rails core member Pratik said that it should stay as a plugin for now. You can see the ticket &lt;a href=&quot;http://rails.lighthouseapp.com/projects/8994/tickets/395-link_to_tagged_current&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/2</id>
    <published>2008-03-13T00:00:00Z</published>
    <updated>2011-03-15T03:06:48Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2008/3/13/error_message_for-not-error_messages_for"/>
    <title>error_message_for (not error_messages_for)</title>
    <content type="html">&lt;p&gt;Sometimes I want to print each error of a form right below the input/select box. And at the same time let the user know that there were problems.&lt;/p&gt;
&lt;p&gt;If I use error_messages_for, I will be showing the user each error twice&#8230; not a good idea.&lt;/p&gt;
&lt;p&gt;So for this case I wrote error_message_for, a method that tells you that there is something wrong whether you have 1 error or more. It also accepts more than one model.&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;3&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;&lt;span class=&quot;r&quot;&gt;def&lt;/span&gt; &lt;span class=&quot;fu&quot;&gt;error_message_for&lt;/span&gt;(*args)&lt;tt&gt;
&lt;/tt&gt;  &lt;span class=&quot;s&quot;&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;&amp;lt;p id='errorExplanation'&amp;gt;Oops, enter correct info.&amp;lt;/p&amp;gt;&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;r&quot;&gt;if&lt;/span&gt; args.any? {|o| error_messages_for(o).size &amp;gt; &lt;span class=&quot;i&quot;&gt;0&lt;/span&gt; }&lt;tt&gt;
&lt;/tt&gt;&lt;span class=&quot;r&quot;&gt;end&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Some usage examples are:&lt;/p&gt;
&lt;table class=&quot;CodeRay&quot;&gt;&lt;tr&gt;
  &lt;td class=&quot;line_numbers&quot; title=&quot;click to toggle&quot; onclick=&quot;with (this.firstChild.style) { display = (display == '') ? 'none' : '' }&quot;&gt;&lt;pre&gt;1&lt;tt&gt;
&lt;/tt&gt;2&lt;tt&gt;
&lt;/tt&gt;&lt;/pre&gt;&lt;/td&gt;
  &lt;td class=&quot;code&quot;&gt;&lt;pre ondblclick=&quot;with (this.style) { overflow = (overflow == 'auto' || overflow == '') ? 'visible' : 'auto' }&quot;&gt;error_message_for &lt;span class=&quot;sy&quot;&gt;:account&lt;/span&gt;&lt;tt&gt;
&lt;/tt&gt;error_message_for &lt;span class=&quot;sy&quot;&gt;:account&lt;/span&gt;, &lt;span class=&quot;sy&quot;&gt;:user&lt;/span&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;&lt;/table&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
  <entry>
    <id>tag:arydjmal.com,2005:Post/1</id>
    <published>2008-02-05T00:00:00Z</published>
    <updated>2010-01-12T02:37:34Z</updated>
    <link rel="alternate" type="text/html" href="http://arydjmal.com/2008/2/5/rails-built-in-timezones-are-awesome"/>
    <title>Rails built-in timezones are awesome!</title>
    <content type="html">&lt;p&gt;You probably know that rails edge sports some very good goodies. But after using rails time zones, I was really amazed how they solved a not-so-fun &#8220;problem&#8221; like timezones.&lt;/p&gt;
&lt;p&gt;Thank you for making my life easier!&lt;/p&gt;
&lt;p&gt;Really looking forward to Rails 2.1.&lt;/p&gt;</content>
    <author>
      <name>Ary Djmal</name>
    </author>
  </entry>
</feed>
