<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>SeeSaw's blog: Category Tips &amp; Tricks</title>
    <link>http://blog.seesaw.it/articles/category/tips-and-tricks</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>...read our minds.</description>
    <item>
      <title>File Encoding Conversion</title>
      <description>&lt;p&gt;This morning I struggled a bit to find  a decent encoding converter for osx&amp;#8230; from time to time I get stuck on encoding issues so I wanted to have something &amp;#8216;friendly&amp;#8217;  to handle this kind of problems&amp;#8230;&lt;/p&gt;


	&lt;p&gt;I found &lt;a href="http://free.abracode.com/cyclone/"&gt;Cyclone&lt;/a&gt; based on &lt;a href="http://developer.apple.com/sdk/"&gt;Apple Text Encoding Converter&lt;/a&gt; (look for &lt;span class="caps"&gt;TEC&lt;/span&gt;) but it kept failing in some strange ways (It gave me weird messages about converters creation).  After googling for a while I gave up. It seems there are no good-free-GUI alternatives on the net&amp;#8230;&lt;/p&gt;


	&lt;p&gt;Sometimes the solution is closer than you think and the good old &lt;a href="http://www.gnu.org/software/libiconv/documentation/libiconv/iconv.1.html"&gt;iconv&lt;/a&gt; rescued me in a snap:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;[paolo@fingus]$ iconv -f UTF-16 -t UTF-8 utf16_file.txt &amp;gt; utf8_file.txt&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;you can list the available encodings with:&lt;/p&gt;


	&lt;p&gt;&lt;code&gt;[paolo@fingus]$ iconv -l&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;The cool part is you can use it in conjunction with &lt;a href="http://www.bestechvideos.com/2007/04/29/textmate-filter-through-command"&gt;TextMate&amp;#8217;s Filter Through Command&lt;/a&gt; feature thus enabling  in-editor lightning-fast conversions.&lt;/p&gt;


	&lt;p&gt;The only missing part was discovering the original file&amp;#8217;s encoding, in order to pass iconv the correct -f option. The not-so-reliable way I used was to open the file with Firefox and inspect the encoding using the &lt;strong&gt;View -&amp;gt; Character Encoding&lt;/strong&gt; menu item.&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s it,  problem solved. 
If you know better ways to do this&amp;#8230; let me know!&lt;/p&gt;
</description>
      <pubDate>Wed, 27 Feb 2008 12:47:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:77fdacfa-1562-4b7d-816a-e2190a1bd726</guid>
      <author>Paolo</author>
      <link>http://blog.seesaw.it/articles/2008/02/27/file-encoding-conversion</link>
      <category>Tips &amp; Tricks</category>
      <category>encoding</category>
      <trackback:ping>http://blog.seesaw.it/articles/trackback/344749</trackback:ping>
    </item>
    <item>
      <title>SpringFramework meeting report</title>
      <description>&lt;p&gt;Last weekend I had the opportunity to give a speech at the &lt;a href="http://www.jugsardegna.org/vqwiki/jsp/Wiki?14Luglio2007"&gt;Spring Framework meeting&lt;/a&gt; in Cagliari.&lt;/p&gt;


	&lt;p&gt;&lt;a href="http://picasaweb.google.com/paolo.dona/SpringMeetingCagliari/photo#5088230501273746434"&gt;&lt;img src="http://lh6.google.com/paolo.dona/Rp0Grqu6vAI/AAAAAAAABJQ/x9Z82hQw_Q4/s400/SSL11769.JPG" /&gt;&lt;/a&gt;&lt;/p&gt;


	&lt;p&gt;My speech was about new features I and Michele added to the Java &lt;a href="http://www.parancoe.org"&gt;Parancoe framework&lt;/a&gt;, &lt;strong&gt;fixtures&lt;/strong&gt; and &lt;strong&gt;plugins&lt;/strong&gt; (the Parancoe website hasn&amp;#8217;t been migrated from the &lt;a href="https://parancoe.dev.java.net"&gt;old java.net one&lt;/a&gt; yet so be patient).&lt;/p&gt;


	&lt;p&gt;I think Parancoe is now the only Java framework  that supports &lt;a href="http://www.yaml.org"&gt;Yaml fixtures&lt;/a&gt; as RubyOnRails does, and that&amp;#8217;s pretty cool because we can now have solid functional tests and we can share test data between the test and development environment.&lt;/p&gt;


	&lt;p&gt;The pluggability of Parancoe it&amp;#8217;s a cool feature too, we can now extend the framework without cluttering the core&amp;#8230; You just define a fragment of a web application and you can put its jar file in the classpath, thus enabling the plugin. 
Plugins can autocreate tables, populate them with yaml fixtures, expose DAOs, business services, controllers and can interact with the application lifecycle (filters/interceptors or context listeners).&lt;/p&gt;


	&lt;p&gt;An example? the &lt;strong&gt;Italy Plugin&lt;/strong&gt;. If you drop the &lt;code&gt;parancoe-plugin-italy.jar&lt;/code&gt; in your classpath your application will be blessed with 4 new auto-created tables: Comuni, Provincie, Regioni, Procure. Those tables get auto-populated with real data when your app starts, and you&amp;#8217;ll automatically have the spring managed DAOs you need to interact with these tables exposed in your spring context. Having these kind of modules simplify and quickens the development of your Java applications.&lt;/p&gt;


	&lt;p&gt;Many other plugins are on the way, &lt;strong&gt;World Plugin&lt;/strong&gt; and &lt;strong&gt;Security Plugin&lt;/strong&gt; on top of them.&lt;/p&gt;


	&lt;p&gt;PS: If you&amp;#8217;re interested in the Parancoe framework, drop me a line or put a comment here.&lt;/p&gt;


	&lt;p&gt;Getting back to the &lt;strong&gt;SpringMeeting&lt;/strong&gt;. I&amp;#8217;ll point you to a few resources:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;Our friend &lt;a href="http://benfante.blogspot.com"&gt;Lucio Benfante&lt;/a&gt; gave a speech on Parancoe too and wrote a &lt;a href="http://benfante.blogspot.com/2007/07/spring-meeting-2007.html"&gt;good article&lt;/a&gt; about the event.&lt;/li&gt;
		&lt;li&gt;There is a report of the trip on the &lt;a href="http://www.jugpadova.it/articles/2007/07/20/gita-in-sardegna"&gt;&lt;span class="caps"&gt;JUG&lt;/span&gt; Padova website&lt;/a&gt;.&lt;/li&gt;
		&lt;li&gt;You can download the Parancoe source code with examples and plugins at &lt;a href="http://code.google.com/p/parancoe"&gt;http://code.google.com/p/parancoe&lt;/a&gt;.&lt;/li&gt;
		&lt;li&gt;You can ask more about Parancoe on the &lt;a href="http://groups.google.com/group/jugpadova"&gt;&lt;span class="caps"&gt;JUG&lt;/span&gt; Padova mailing list&lt;/a&gt;.&lt;/li&gt;
		&lt;li&gt;Pictures of the event: &lt;a href="http://picasaweb.google.com/paolo.dona/SpringMeetingCagliari"&gt;mine&lt;/a&gt;, &lt;a href="http://www.flickr.com/photos/benfante/tags/springmeeting2007"&gt;Lucio&lt;/a&gt; &amp;#38; &lt;a href="http://www.flickr.com/photos/96509429@N00/tags/springframework2007cagliari"&gt;Massimiliano&lt;/a&gt;.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;That&amp;#8217;s it for now&amp;#8230;&lt;/p&gt;
</description>
      <pubDate>Fri, 20 Jul 2007 09:35:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:b60baf4c-31bd-4298-951c-973c488a7b98</guid>
      <author>Paolo</author>
      <link>http://blog.seesaw.it/articles/2007/07/20/springframework-meeting-report</link>
      <category>Web</category>
      <category>Java</category>
      <category>Tips &amp; Tricks</category>
      <category>parancoe</category>
      <category>paolodona</category>
      <category>springframework</category>
      <category>web</category>
      <category>development</category>
      <category>cagliari</category>
      <category>jugpadova</category>
      <trackback:ping>http://blog.seesaw.it/articles/trackback/181235</trackback:ping>
    </item>
    <item>
      <title>Todo list and next action with GMail</title>
      <description>&lt;p&gt;I&amp;#8217;m kind of getting into &lt;acronym title="Getting Thigs Done"&gt;GTD&lt;/acronym&gt; during this period, but I find myself very lazy at organizing my stuff. I find it pretty difficult to stick with a specific tool for managing my todo list. Basically I don&amp;#8217;t want to use yet another tool, and I feel I would only need a quick and dirty solution to track my todo items and my very next actions.&lt;/p&gt;


	&lt;p&gt;After trying a bunch of tools I came out with this simple solution: I store todo items in my  GMail account.  Nothing new or very smart, but it works pretty well. Let&amp;#8217;s see how to do it:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;create a new contact named &lt;strong&gt;todo&lt;/strong&gt; whose email is &lt;strong&gt;&lt;em&gt;your_account_name&lt;/em&gt;+todo@gmail.com&lt;/strong&gt; (eg: &lt;code&gt;paolo.dona+todo@gmail.com&lt;/code&gt;)&lt;/li&gt;
		&lt;li&gt;create a label &lt;strong&gt;todo&lt;/strong&gt;&lt;/li&gt;
		&lt;li&gt;create a filter that matches &lt;strong&gt;to:(&lt;em&gt;your_account_name&lt;/em&gt;+todo@gmail.com)&lt;/strong&gt; and do this: &lt;strong&gt;Skip Inbox, Apply label &amp;#8220;todo&amp;#8221;&lt;/strong&gt;.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;Once you&amp;#8217;ve completed these little steps, you can start using your brand new todo-list manager. Oh well, I haven&amp;#8217;t told you how to use it yet&amp;#8230; so:&lt;/p&gt;


	&lt;h4&gt;How to add a todo item?&lt;/h4&gt;


	&lt;p&gt;Send an email to your &lt;strong&gt;todo&lt;/strong&gt; contact (It&amp;#8217;s just yourself!) and it will be automatically archived, this way it doesn&amp;#8217;t clutter your inbox.&lt;/p&gt;


	&lt;h4&gt;How to see your pending items?&lt;/h4&gt;


	&lt;p&gt;Click on your &lt;strong&gt;todo&lt;/strong&gt; label inside the left Labels box.&lt;/p&gt;


	&lt;h4&gt;How to mark a todo item as finished?&lt;/h4&gt;


	&lt;p&gt;Delete it. (YOU said it&amp;#8217;s finished :-P)&lt;/p&gt;


	&lt;h4&gt;How to mark a todo item as a &amp;#8220;next action&amp;#8221;?&lt;/h4&gt;


	&lt;p&gt;Star it.&lt;/p&gt;


	&lt;h4&gt;How to see you next actions?&lt;/h4&gt;


	&lt;p&gt;Run this search: &lt;strong&gt;label:todo is:starred&lt;/strong&gt;. Actually I&amp;#8217;m using the &lt;a href="http://code.google.com/p/gmail-greasemonkey"&gt;saved searches&lt;/a&gt;  &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/748"&gt;greasemonkey&lt;/a&gt; script to save this query and have it available as a &lt;strong&gt;next actions&lt;/strong&gt; link just under my Labels box.&lt;/p&gt;


	&lt;h3&gt;Conclusions&lt;/h3&gt;


	&lt;p&gt;This approach is very simple but I see a few key benefits in it:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;Gmail is always open in my browser, I don&amp;#8217;t need to keep another window or tab open  just to see my todos.&lt;/li&gt;
		&lt;li&gt;I can add filters that automatically populate my todo list. For example my Google Calendar reminders get labelled as &lt;strong&gt;todo&lt;/strong&gt; so I can see them in my todo list. The same happens with &lt;a href="http://www.basecamphq.com"&gt;Basecamp&lt;/a&gt; or &lt;a href="http://www.highrisehq.com"&gt;Highrise&lt;/a&gt; todo item/task notifications.&lt;/li&gt;
		&lt;li&gt;You can play with labels and easily let todo items belong to projects, locations etc (GTD style).&lt;/li&gt;
		&lt;li&gt;You can reply to your todo items to add comments or further details to the activity they refer to.&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;Feel free to share your ideas on this.&lt;/p&gt;
</description>
      <pubDate>Mon, 07 May 2007 13:49:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:60fe2374-acd5-4d95-8840-df1e5948a201</guid>
      <author>Paolo</author>
      <link>http://blog.seesaw.it/articles/2007/05/07/todo-list-and-next-action-with-gmail</link>
      <category>Tips &amp; Tricks</category>
      <category>GTD</category>
      <category>gmail</category>
      <category>todo</category>
      <category>productivity</category>
      <trackback:ping>http://blog.seesaw.it/articles/trackback/104537</trackback:ping>
    </item>
    <item>
      <title>DNS shortcuts by OpenDNS</title>
      <description>&lt;p&gt;Today I discovered a nice feature of &lt;a href="http://opendns.com"&gt;OpenDNS&lt;/a&gt;: if you register an account in opendns.com you will be able to map &lt;span class="caps"&gt;URL&lt;/span&gt; shortucts to web sites. They will be recognized automatically when you type them in your preferred web browser. For example I mapped &amp;#8220;mail&amp;#8221; to http://mail.seesaw.it, and this allow me to open my webmail page just typing &amp;#8220;mail&amp;#8221; in my firefox navigation bar.  This could be even faster than using a bookmark if you&amp;#8217;re already using keyboard shortcuts in your browser.&lt;/p&gt;


	&lt;p&gt;A sample: I often need to open the SeeSaw&amp;#8217;s Basecamp account (http://seesaw.seework.com). I registered an OpenDNS shortcut named &amp;#8220;bc&amp;#8221; that points to that &lt;span class="caps"&gt;URL&lt;/span&gt; and now I can do something like:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;open firefox (ALT+SPACE, type &amp;#8220;f&amp;#8221; then &lt;span class="caps"&gt;ENTER&lt;/span&gt;) using &lt;a href="http://www.lauchy.net"&gt;Launchy&lt;/a&gt;.&lt;/li&gt;
		&lt;li&gt;open basecamp in firefox (CTRL+L, type &amp;#8220;bc&amp;#8221; then &lt;span class="caps"&gt;ENTER&lt;/span&gt;)&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Pretty cool! Of course you need to use OpenDNS in order to make that work..
Happy shortcutting!&lt;/p&gt;
</description>
      <pubDate>Mon, 23 Apr 2007 14:34:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:6a07089b-a7fb-436e-b854-ecc7feeb613f</guid>
      <author>Paolo</author>
      <link>http://blog.seesaw.it/articles/2007/04/23/dns-shortcuts-by-opendns</link>
      <category>Tips &amp; Tricks</category>
      <category>OpenDNS</category>
      <category>shortcut</category>
      <trackback:ping>http://blog.seesaw.it/articles/trackback/95342</trackback:ping>
    </item>
    <item>
      <title>Fixing KRJS</title>
      <description>&lt;p&gt;A few days ago I discovered the great &lt;a href="http://blog.yanime.org/articles/2006/06/12/krjs-rjs-without-messing-the-views"&gt;&lt;span class="caps"&gt;KRJS&lt;/span&gt; Plugin&lt;/a&gt; for RubyOnRails. It basically lets you write callbacks methods in your controller and binds them to ajax calls based on a naming convention.&lt;/p&gt;


You can write something like this:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;on_account_login_blur&lt;/span&gt;
   &lt;span class="ident"&gt;render&lt;/span&gt; &lt;span class="symbol"&gt;:update&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;page&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;
      &lt;span class="ident"&gt;page&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;insert_html&lt;/span&gt; &lt;span class="symbol"&gt;:after&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;form&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;...&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
   &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;that is automatically &lt;span class="caps"&gt;AJAX&lt;/span&gt;-invoked at the &lt;code&gt;onBlur&lt;/code&gt; event in the &lt;code&gt;account_login&lt;/code&gt; input field.&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;KRJS&lt;/span&gt; inserts the &lt;code&gt;onBlur&lt;/code&gt; event in your field if it finds a matching method in the current controller.&lt;/p&gt;


The only issue with this plugin is that it redefines &lt;code&gt;TagHelper&lt;/code&gt;&amp;#8217;s &lt;code&gt;tag&lt;/code&gt; and &lt;code&gt;content_tag&lt;/code&gt; methods. So, if you&amp;#8217;re using something like:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="constant"&gt;ActionView&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Base&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;field_error_proc&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="constant"&gt;Proc&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;new&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;html&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;instance&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt;
  &lt;span class="comment"&gt;# customization of your error messages here&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt; 
...you&amp;#8217;re losing all your error handling goodness. 
I struggled a bit with this and end up rewiting &lt;span class="caps"&gt;KRJS&lt;/span&gt; to use the rails &lt;code&gt;alias_method_chain&lt;/code&gt; over the original &lt;code&gt;tag&lt;/code&gt; and &lt;code&gt;content_tag&lt;/code&gt; methods. While doing this I also tried to clean up the code a bit.

	&lt;p&gt;So if you&amp;#8217;re interested you can download my version &lt;a href="http://blog.seesaw.it/files/krjs.zip"&gt;here&lt;/a&gt;,. Don&amp;#8217;t be afraid to report any issue, it&amp;#8217;s alpha code &amp;#8230;&lt;/p&gt;


	&lt;p&gt;Good AJAXing&lt;/p&gt;
</description>
      <pubDate>Fri, 02 Mar 2007 13:19:00 -0600</pubDate>
      <guid isPermaLink="false">urn:uuid:79d7b4c4-5dde-4d57-9c6d-93afd17e59b8</guid>
      <author>Paolo</author>
      <link>http://blog.seesaw.it/articles/2007/03/02/fixing-krjs</link>
      <category>Tips &amp; Tricks</category>
      <category>krjs</category>
      <category>ajax</category>
      <category>ruby</category>
      <category>Ruby On Rails</category>
      <category>javascript</category>
      <enclosure url="http://blog.seesaw.it/files/krjs.zip" type="application/zip" length="11144"/>
      <trackback:ping>http://blog.seesaw.it/articles/trackback/68830</trackback:ping>
    </item>
    <item>
      <title>Auto-Completion in Irb</title>
      <description>&lt;p&gt;A fast &amp;#38; effective way for having auto-completion in irb (with some limitation) via &lt;a href="http://webonrails.wordpress.com/2006/10/07/tab-completion-in-irb/"&gt;web on rails&lt;/a&gt;&lt;/p&gt;
</description>
      <pubDate>Tue, 17 Oct 2006 15:12:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:5e1b14c5-6134-44bd-b5b2-e3105fdfcdd1</guid>
      <author>Michele</author>
      <link>http://blog.seesaw.it/articles/2006/10/17/tab-completion-in-irb</link>
      <category>Tips &amp; Tricks</category>
      <category>irb</category>
      <category>ruby</category>
      <category>auto</category>
      <category>completion</category>
      <category>tab</category>
      <trackback:ping>http://blog.seesaw.it/articles/trackback/10318</trackback:ping>
    </item>
    <item>
      <title>Getting MIME type from a file</title>
      <description>&lt;p&gt;It&amp;#8217;s pretty simple: just grab activation framework from the web and type:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ "&gt;import javax.activation.MimetypesFileTypeMap;
import java.io.File;
...
File file = new File(&amp;quot;WhoAmI.jpg&amp;quot;);

System.out.println(&amp;quot;MIME type of &amp;quot; +
  file.getName() + &amp;quot; is &amp;quot; +
  new MimetypesFileTypeMap().getContentType(file)
);&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;The expected output is:&lt;/p&gt;


	&lt;p&gt;&lt;span class="shell"&gt;&lt;span class="caps"&gt;MIME&lt;/span&gt; type of WhoAmI.jpg is image/jpeg&lt;/span&gt;&lt;/p&gt;


	&lt;p&gt;simple and effective, isn&amp;#8217;t it?&lt;/p&gt;


	&lt;p&gt;&lt;span class="caps"&gt;UPDATE&lt;/span&gt;: If you want to detect types other than simple images you should integrate the activation framework default list as stated in the &lt;a href="http://java.sun.com/products/javabeans/glasgow/javadocs/javax/activation/MimetypesFileTypeMap.html"&gt;javadoc&lt;/a&gt; .
For example detection of a zip archive can be done by adding this:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ "&gt;MimetypesFileTypeMap mt = new MimetypesFileTypeMap();
mt.addMimeTypes(&amp;quot;application/x-zip zip ZIP&amp;quot;);&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
</description>
      <pubDate>Sat, 09 Sep 2006 22:56:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:ff9cc76a-73ee-4702-b244-b85c13fa546b</guid>
      <author>Michele</author>
      <link>http://blog.seesaw.it/articles/2006/09/09/getting-mime-type-from-a-file</link>
      <category>Java</category>
      <category>Tips &amp; Tricks</category>
      <category>mime</category>
      <category>type</category>
      <category>file</category>
      <category>java</category>
      <trackback:ping>http://blog.seesaw.it/articles/trackback/5802</trackback:ping>
    </item>
    <item>
      <title>The easiest way to add tabbed navigation to your Rails app!</title>
      <description>&lt;p&gt;&lt;b&gt;&lt;span class="caps"&gt;UPDATE&lt;/span&gt; Feb 01, 2007:  the Tabnav has been updated in order to work wit Rails 1.2,   read &lt;a href="http://blog.seesaw.it/articles/2007/02/01/tabnav-for-rails-1-2"&gt;this post&lt;/a&gt; fom more info.&lt;/b&gt;&lt;/p&gt;


	&lt;p&gt;Hi guys, during our development efforts we needed tabbed navigations. Well, after struggling with the acts_as_wizard plugin (you can find it in the &lt;a href="http://blog.seesaw.it/pages/toolbox"&gt;toolbox&lt;/a&gt;) we decided to implement yet another rails plugin, and we think this time it&amp;#8217;s even easier  to use and someway plain cool.&lt;/p&gt;


	&lt;p&gt;Tabnav it&amp;#8217;s so far the easiest way to build tabbed navigation like this:&lt;/p&gt;


&lt;div style="" class="flickrplugin"&gt;&lt;a href="http://www.flickr.com/photos/seesawstaff/196253571"&gt;&lt;img src="http://farm1.static.flickr.com/61/196253571_c7cf688f2b.jpg" width="428" height="265" alt="A basic Tabnav..." title="A basic Tabnav..."/&gt;&lt;/a&gt;&lt;p class="caption" style="width:428px"&gt;The Tabnav Rails plugin provides nice tabbed navigation out of the box &lt;/p&gt;&lt;/div&gt;

	&lt;p&gt;All this magic it&amp;#8217;s done by this fragment of code put inside my layout:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="punct"&gt;&amp;lt;%=&lt;/span&gt;&lt;span class="string"&gt; start_tabnav :main %&amp;gt;
&amp;lt;%&lt;/span&gt;&lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="attribute"&gt;@content_for_layout&lt;/span&gt; &lt;span class="punct"&gt;%&amp;gt;&lt;/span&gt;&lt;span class="string"&gt;
&amp;lt;%= end_tabnav %&lt;/span&gt;&lt;span class="punct"&gt;&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Sounds cool? keep reading&amp;#8230;&lt;/p&gt;
&lt;p&gt;Where does the start_tabnav gets informations  for tabs rendering? The :main Symbol let the &lt;em&gt;start_tabnav&lt;/em&gt; method know to look for a special MainTabnav class where all the magic happens, so in my model directory I&amp;#8217;ve got a &lt;em&gt;main_tabnav.rb&lt;/em&gt; file containing something like:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;MainTabnav&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="constant"&gt;Tabnav&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Base&lt;/span&gt;       
  &lt;span class="ident"&gt;add_tab&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; 
    &lt;span class="ident"&gt;named&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;Dashboard&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
    &lt;span class="ident"&gt;titled&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;Wooooow! what a wonderful tabbed navigation!&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
    &lt;span class="ident"&gt;links_to&lt;/span&gt; &lt;span class="symbol"&gt;:controller&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;dashboard&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;

  &lt;span class="ident"&gt;add_tab&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; 
    &lt;span class="ident"&gt;named&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;Users&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
    &lt;span class="ident"&gt;links_to&lt;/span&gt; &lt;span class="symbol"&gt;:controller&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;users&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt; 

  &lt;span class="ident"&gt;add_tab&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; 
    &lt;span class="ident"&gt;named&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;Companies&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
    &lt;span class="ident"&gt;links_to&lt;/span&gt; &lt;span class="symbol"&gt;:controller&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;companies&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
    &lt;span class="ident"&gt;highlights_on&lt;/span&gt; &lt;span class="symbol"&gt;:controller&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;dashboard&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="symbol"&gt;:action&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;statistics&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt; 

  &lt;span class="ident"&gt;add_tab&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; 
    &lt;span class="ident"&gt;named&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;Admin&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
    &lt;span class="ident"&gt;links_to&lt;/span&gt; &lt;span class="symbol"&gt;:controller&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;companies&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
    &lt;span class="ident"&gt;show_if&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;params[:admin] == true&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;      
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;This way you can manage your tabs in a view-indipendent manner. The MainTabnav class should be pretty self-explanatory&amp;#8230; but let me point out a few nice features:&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;The &lt;em&gt;titled&lt;/em&gt; method gives your tabs a html &amp;#8216;title&amp;#8217; attribute so you can have tooltips over your tab link.&lt;/li&gt;
		&lt;li&gt;The &lt;em&gt;links_to&lt;/em&gt; method creates the tab&amp;#8217;s link. You can use the same options as the usual ActionView&amp;#8217;s &lt;em&gt;url_for&lt;/em&gt;. The tab will be automatically highlighted (with the help of a &lt;span class="caps"&gt;CSS&lt;/span&gt; class) if the page you&amp;#8217;re viewing matches the &lt;em&gt;links_to&lt;/em&gt; options. So if you&amp;#8217;re linking to :controller =&amp;gt; &amp;#8216;dashboard&amp;#8217;, you can be sure every dashboard&amp;#8217;s action will keep the tab highlighted. If you&amp;#8217;re linking to :controller =&amp;gt; &amp;#8216;dashboard&amp;#8217;, :action =&amp;gt; &amp;#8216;index&amp;#8217; only the index action will highlight it.&lt;/li&gt;
		&lt;li&gt;You can add more highlighting rules using the &lt;em&gt;highligths_on&lt;/em&gt; method. This could be useful if you have more than one controller that should highlight the same tab (eg: think about an estimate wizard involving multliple controllers, keeping an &amp;#8216;estimates&amp;#8217; tab highlighted).&lt;/li&gt;
		&lt;li&gt;You can conditionally choose to show or not show a tab given a certain condition with the &lt;em&gt;show_if&lt;/em&gt; method. The string parameter given will be evaluated in the view context, so you can show admin pages tabs only to administrators and so on.&lt;/li&gt;
	&lt;/ul&gt;


	&lt;h3&gt;It&amp;#8217;s cool! Tell me how to use it!&lt;/h3&gt;


	&lt;p&gt;Install it from your rails base directory with this:
&lt;span class="shell"&gt;ruby script/plugin install svn://svn.seesaw.it/tabnav/tags/0.1&lt;/span&gt;&lt;/p&gt;


	&lt;p&gt;And generate how many tabbed navigations you like with:&lt;/p&gt;


	&lt;p&gt;&lt;span class="shell"&gt;ruby script/generate tabnav Main&lt;/span&gt;&lt;/p&gt;


	&lt;p&gt;Of course you can substitute &amp;#8216;Main&amp;#8217; with the desired prefix of your tabnav class.&lt;/p&gt;


	&lt;p&gt;Then configure your Tabnav model as you desire and include a start_tabnav/end_tabnav statement in your layout or view files.&lt;/p&gt;


	&lt;h3&gt;Can I customize the generated &lt;span class="caps"&gt;HTML&lt;/span&gt;/CSS?&lt;/h3&gt;


	&lt;p&gt;The tabnav generator will create a partial file inside  your view/tabnav directory. There you can customize the html and the inline &lt;span class="caps"&gt;CSS&lt;/span&gt; used by your tabnav. You can move the inline &lt;span class="caps"&gt;CSS&lt;/span&gt; to you stylesheet file too.&lt;/p&gt;


	&lt;h3&gt;Can I nest navigations?&lt;/h3&gt;


	&lt;p&gt;Yes of course, with tabnav you can easily do something like:&lt;/p&gt;


&lt;div style="" class="flickrplugin"&gt;&lt;a href="http://www.flickr.com/photos/seesawstaff/196286898"&gt;&lt;img src="http://farm1.static.flickr.com/62/196286898_4700d000ff.jpg" width="412" height="320" alt="Nested Tabnavs" title="Nested Tabnavs"/&gt;&lt;/a&gt;&lt;p class="caption" style="width:412px"&gt;You can easily nest tabnavs. They rely on their own model, partial and CSS stylesheet. &lt;/p&gt;&lt;/div&gt;

	&lt;h3&gt;Another little trick&amp;#8230;&lt;/h3&gt;


	&lt;p&gt;Last but not least you can have tabbed navigations without having a whole &amp;#8216;containing box&amp;#8217; using just a:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="punct"&gt;&amp;lt;%=&lt;/span&gt;&lt;span class="string"&gt; tabnav :main %&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;This way you can do stuff like:&lt;/p&gt;


&lt;div style="" class="flickrplugin"&gt;&lt;a href="http://www.flickr.com/photos/seesawstaff/196293735"&gt;&lt;img src="http://farm1.static.flickr.com/74/196293735_2f8e80d749.jpg" width="500" height="288" alt="Tabnavs with/without boxes." title="Tabnavs with/without boxes."/&gt;&lt;/a&gt;&lt;p class="caption" style="width:500px"&gt;You can have just navigation tabs without the whole box attached under them&lt;/p&gt;&lt;/div&gt;

	&lt;p&gt;That&amp;#8217;s it right now guys. Hope you find it useful!
Don&amp;#8217;t forget we need feedback, so feel free to comment on this post or send us a private &lt;a href="mailto:staff@seesaw.it"&gt;email&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;If you want to keep in touch with further developments  you can even subscribe to our &lt;a href="http://blog.seesaw.it/xml/rss20/feed.xml"&gt;rss feed&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;This plugin is part of the SeeSaw&amp;#8217;s &lt;a href="http://blog.seesaw.it/pages/toolbox"&gt;toolbox&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;having trouble downloading the plugin? You can install it without subversion:&lt;/p&gt;


	&lt;p&gt;In vendor/plugins, create directory tabnav. In that directory download
end extract &lt;a href="http://svn.seesaw.it/pkgs/tabnav.tar.gz"&gt;this&lt;/a&gt;!&lt;/p&gt;


	&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Due to a server migration, we&amp;#8217;ve moved our repositories to a new location&amp;#8230; see &lt;a href="http://blog.seesaw.it/articles/2006/11/18/tabnav-svn-repo-has-changed"&gt;this&lt;/a&gt; for more info.&lt;/p&gt;</description>
      <pubDate>Sun, 23 Jul 2006 20:09:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:df5ef49d-42a9-4447-a141-81f275f3fbc6</guid>
      <author>Paolo</author>
      <link>http://blog.seesaw.it/articles/2006/07/23/the-easiest-way-to-add-tabbed-navigation-to-your-rails-app</link>
      <category>Web</category>
      <category>Ruby + Rails</category>
      <category>Tips &amp; Tricks</category>
      <category>tabnav</category>
      <category>toolbox</category>
      <category>Ruby On Rails</category>
      <category>plugin</category>
      <trackback:ping>http://blog.seesaw.it/articles/trackback/839</trackback:ping>
    </item>
    <item>
      <title>acts_as_wizard refactored!</title>
      <description>&lt;p&gt;Our &lt;em&gt;acts_as_wizard&lt;/em&gt; plugin needed improvements to address a few needs
of an application we&amp;#8217;re currently working on. I promised improvements to a bunch of early adopters too so finally I took my time and have done this dirty work.&lt;/p&gt;


	&lt;p&gt;If you don&amp;#8217;t know &lt;em&gt;acts_as_wizard&lt;/em&gt; yet, you just need to know
it&amp;#8217;s a &lt;a href="http://www.rubyonrails.org"&gt;rails&lt;/a&gt; &lt;a href="http://wiki.rubyonrails.org/rails/pages/HowTosPlugins"&gt;plugin&lt;/a&gt; to help you build clean and simple web wizards.&lt;/p&gt;


	&lt;p&gt;You can find &lt;em&gt;acts_as_wizard&lt;/em&gt; articles, installation instructions, tutorials and previous posts in the SeeSaw&amp;#8217;s &lt;a href="http://blog.seesaw.it/pages/toolbox"&gt;toolbox&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;A Wizard can be simply defined this way:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;CreateCatAndDogWizard&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="constant"&gt;Wizard&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Base&lt;/span&gt;     
    &lt;span class="ident"&gt;add_step&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; 
      &lt;span class="ident"&gt;named&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;Insert your cat&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
      &lt;span class="ident"&gt;controlled_by&lt;/span&gt; &lt;span class="symbol"&gt;:cats&lt;/span&gt;
      &lt;span class="ident"&gt;enable_actions&lt;/span&gt; &lt;span class="symbol"&gt;:new&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="symbol"&gt;:create&lt;/span&gt;
      &lt;span class="ident"&gt;add_rewrite&lt;/span&gt;&lt;span class="punct"&gt;({&lt;/span&gt;&lt;span class="symbol"&gt;:action&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;list&lt;/span&gt;&lt;span class="punct"&gt;'},&lt;/span&gt; 
                  &lt;span class="punct"&gt;{&lt;/span&gt;&lt;span class="symbol"&gt;:controller&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;dogs&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="symbol"&gt;:action&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;'})&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt; 

    &lt;span class="ident"&gt;add_step&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
      &lt;span class="ident"&gt;named&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;Insert your dog&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
      &lt;span class="ident"&gt;controlled_by&lt;/span&gt; &lt;span class="symbol"&gt;:dogs&lt;/span&gt;
      &lt;span class="ident"&gt;enable_actions&lt;/span&gt; &lt;span class="symbol"&gt;:new&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="symbol"&gt;:create&lt;/span&gt;
      &lt;span class="ident"&gt;add_rewrite&lt;/span&gt;&lt;span class="punct"&gt;({&lt;/span&gt;&lt;span class="symbol"&gt;:action&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;list&lt;/span&gt;&lt;span class="punct"&gt;'},&lt;/span&gt; 
                  &lt;span class="punct"&gt;{&lt;/span&gt;&lt;span class="symbol"&gt;:controller&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;main&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="symbol"&gt;:action&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;finished&lt;/span&gt;&lt;span class="punct"&gt;'})&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt; 

    &lt;span class="ident"&gt;add_step&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt; 
      &lt;span class="ident"&gt;named&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;Finished!&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
      &lt;span class="ident"&gt;controlled_by&lt;/span&gt; &lt;span class="symbol"&gt;:main&lt;/span&gt;
      &lt;span class="ident"&gt;enable_actions&lt;/span&gt; &lt;span class="symbol"&gt;:finished&lt;/span&gt; 
    &lt;span class="keyword"&gt;end&lt;/span&gt;     
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;The main areas our refactoring focused on are:&lt;/p&gt;


	&lt;ol&gt;
	&lt;li&gt;get rid of every controller contamination: we wanted controllers to be totally unaware of being part of a wizard.&lt;/li&gt;
		&lt;li&gt;multi wizard support: the same controller must be able to take part of different wizards.&lt;/li&gt;
		&lt;li&gt;general code cleanup: well, we just were ashamed of some dirty code..&lt;/li&gt;
	&lt;/ol&gt;


	&lt;p&gt;If you&amp;#8217;ve never uses &lt;em&gt;acts_as_wizard&lt;/em&gt;, you don&amp;#8217;t need to read what follows, just remember it has gotten better :)&lt;/p&gt;


	&lt;p&gt;If you were an early adopter instead, keep reading an I&amp;#8217;ll show you what technically has changed&amp;#8230;&lt;/p&gt;
&lt;h3&gt;Now almost everything is configured in the Wizard class.&lt;/h3&gt;


	&lt;p&gt;You must delete &lt;em&gt;acts_as_wizard&lt;/em&gt; and &lt;em&gt;on_wizard_rewrite&lt;/em&gt; statements from your controllers.&lt;/p&gt;


	&lt;p&gt;The steps definition inside your Wizard class has changed and now supports the &lt;em&gt;add_rewrite&lt;/em&gt; method,
this way you can substitute every controller rewriting with a step&amp;#8217;s &lt;em&gt;add_rewrite&lt;/em&gt; call.&lt;/p&gt;


	&lt;p&gt;The &lt;em&gt;acts_as_wizard&lt;/em&gt; statement has been substituted by the &lt;em&gt;controlled_by&lt;/em&gt; statement inside your step.&lt;/p&gt;


	&lt;p&gt;Controllers are no more tied to a single wizard. The &lt;em&gt;controlled_by&lt;/em&gt; method takes a symbol as parameter, so different wizards can have steps pointing to the same controller.&lt;/p&gt;


	&lt;p&gt;You need just to modify your steps this way:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;add_step&lt;/span&gt; &lt;span class="keyword"&gt;do&lt;/span&gt;
  &lt;span class="ident"&gt;named&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;Insert your cat&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;
  &lt;span class="ident"&gt;controlled_by&lt;/span&gt; &lt;span class="symbol"&gt;:cats&lt;/span&gt;
  &lt;span class="ident"&gt;enable_actions&lt;/span&gt; &lt;span class="symbol"&gt;:new&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="symbol"&gt;:create&lt;/span&gt;
  &lt;span class="ident"&gt;add_rewrite&lt;/span&gt;&lt;span class="punct"&gt;({&lt;/span&gt;&lt;span class="symbol"&gt;:action&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;list&lt;/span&gt;&lt;span class="punct"&gt;'},&lt;/span&gt; 
              &lt;span class="punct"&gt;{&lt;/span&gt;&lt;span class="symbol"&gt;:controller&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;dogs&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt; &lt;span class="symbol"&gt;:action&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;'})&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;The &lt;em&gt;controlled_by&lt;/em&gt; statement will inject necessary objects in your controller.&lt;/p&gt;


	&lt;h3&gt;To start a wizard you need to pass a parameter with the name of your wizard underscored:&lt;/h3&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="punct"&gt;&amp;lt;%=&lt;/span&gt;&lt;span class="string"&gt; link_to 'create a cat and a dog with a wizard',
               :controller &lt;/span&gt;&lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;cats&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt;
               &lt;span class="symbol"&gt;:action&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;new&lt;/span&gt;&lt;span class="punct"&gt;',&lt;/span&gt;
               &lt;span class="symbol"&gt;:wizard&lt;/span&gt; &lt;span class="punct"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;create_cat_and_dog&lt;/span&gt;&lt;span class="punct"&gt;'%&amp;gt;&lt;/span&gt;&lt;span class="string"&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;The :wizard=&amp;gt;true form is no longer valid&lt;/p&gt;


	&lt;h3&gt;You &lt;span class="caps"&gt;MUST&lt;/span&gt; require your wizard class in your application.rb.&lt;/h3&gt;


	&lt;p&gt;This is needed because rails usually requires files only when needed,
but we need to inject wizard objects in involved controllers at startup.&lt;/p&gt;


	&lt;p&gt;PS: require &lt;strong&gt;after&lt;/strong&gt; the ApplicationController declaration.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;ApplicationController&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;&lt;/span&gt; &lt;span class="constant"&gt;ActionController&lt;/span&gt;&lt;span class="punct"&gt;::&lt;/span&gt;&lt;span class="constant"&gt;Base&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="ident"&gt;require&lt;/span&gt; &lt;span class="punct"&gt;'&lt;/span&gt;&lt;span class="string"&gt;create_cat_and_dog_wizard&lt;/span&gt;&lt;span class="punct"&gt;'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;That&amp;#8217;s it for now. 
A further development could be the creation of view helpers to easily start a wizard or go to the prev/next action.&lt;/p&gt;


	&lt;p&gt;Let us know if you got in trouble with it or got ideas to share.&lt;/p&gt;


	&lt;p&gt;Always feel free to drop us an email at staff@seesaw.it and subscribe to our feed if you wanna stay tuned on aaw evolution.&lt;/p&gt;


	&lt;p&gt;You can find more info about the &lt;em&gt;acts_as_wizard&lt;/em&gt; plugin in the &lt;a href="http://blog.seesaw.it/pages/toolbox"&gt;toolbox&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Mon, 17 Jul 2006 23:58:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:60cb54dd-84eb-4b7a-9f77-3df5a9dc95ad</guid>
      <author>Paolo</author>
      <link>http://blog.seesaw.it/articles/2006/07/17/acts_as_wizard-refactored</link>
      <category>Web</category>
      <category>Ruby + Rails</category>
      <category>Tips &amp; Tricks</category>
      <category>Ruby On Rails</category>
      <category>plugin</category>
      <category>acts_as_wizard</category>
      <category>toolbox</category>
      <category>refactoring</category>
      <trackback:ping>http://blog.seesaw.it/articles/trackback/421</trackback:ping>
    </item>
    <item>
      <title>Choose the right killer</title>
      <description>&lt;p&gt;&lt;img src="http://static.flickr.com/58/180831291_15b3b46a5b.jpg" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Sometimes happens that a server process become too lazy, mutate himself into a fat memory 
eater, hang or simply don&amp;#8217;t want to die.&lt;/p&gt;


	&lt;p&gt;If you (like me) are about to say &amp;#8220;Is this a problem? &lt;em&gt;kill -9&lt;/em&gt; is the 
right remedy!&amp;#8221; it&amp;#8217;s time to &lt;a href="http://sial.org/howto/shell/kill-9/"&gt;read&lt;/a&gt; why this way should be used &lt;strong&gt;only&lt;/strong&gt; as
in-case-of-death resource.&lt;/p&gt;
</description>
      <pubDate>Fri, 16 Jun 2006 18:00:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:617e71b9-3163-4f26-87a1-2c76a5fb8d90</guid>
      <author>Michele</author>
      <link>http://blog.seesaw.it/articles/2006/06/16/choose-the-right-killer</link>
      <category>Tips &amp; Tricks</category>
      <category>kill</category>
      <category>process</category>
      <category>server</category>
      <trackback:ping>http://blog.seesaw.it/articles/trackback/95</trackback:ping>
    </item>
  </channel>
</rss>
