<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Artem Vasiliev's Weblog</title>
	<atom:link href="http://thirstydoh.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thirstydoh.wordpress.com</link>
	<description>Development-related blog</description>
	<lastBuildDate>Tue, 27 Oct 2009 08:56:29 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='thirstydoh.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/523cf560ed61a2bd4d3f2ba12e514e5f?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>Artem Vasiliev's Weblog</title>
		<link>http://thirstydoh.wordpress.com</link>
	</image>
			<item>
		<title>error emails digesting: ar_mailer fork</title>
		<link>http://thirstydoh.wordpress.com/2009/10/26/error-emails-digesting-ar_mailer-fork/</link>
		<comments>http://thirstydoh.wordpress.com/2009/10/26/error-emails-digesting-ar_mailer-fork/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 10:31:44 +0000</pubDate>
		<dc:creator>thirstydoh</dc:creator>
				<category><![CDATA[ActionMailer]]></category>
		<category><![CDATA[emailing]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://thirstydoh.wordpress.com/?p=37</guid>
		<description><![CDATA[There&#8217;s an ExceptionNotifier plugin wich makes errors caused in controller action sent to you by email. The problem is that the site sometimes can face an issue that makes it error on nearly each request. The emails make it quickly noticed and fixed appropriately, but if the site have some load there will be significant [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=37&subd=thirstydoh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>There&#8217;s an ExceptionNotifier plugin wich makes errors caused in controller action sent to you by email. The problem is that the site sometimes can face an issue that makes it error on nearly each request. The emails make it quickly noticed and fixed appropriately, but if the site have some load there will be significant number of these error emails which is annoying (or often harmful) considering that you have a limit on SMTP server.</p>
<p>So in my company we wanted to make error email notifications sent by ExceptionNotifier and the likes not sent immediately but combined into digest email each minute. We used <a href="http://github.com/adzap/ar_mailer">adzap-ar_mailer</a> for error messages buffering and then made it combine them to digests based on To field. Also we already had BackgrounDRB so we didn’t need separate ar_sendmail process.</p>
<p>Adzap’s fork is great because you can use ar_mailer for just one class with it &#8211; just what we needed. So we decided to opensource our tweaks in hope that it will be helpful for someone, and put our changes to a fork on GitHub: <a href="http://github.com/artemv/ar_mailer">artemv/ar_mailer</a>. The code is quite limited but it’s fine for our needs, and if you need more you have smth to start with. E.g. it could be improved to support text/html messages or to make certain classes bypass digesting when sending emails with ARMailer.</p>
<p>So, what does this fork do out of the box:</p>
<ul>
<li>ARMailer messages don’t get send until they are combined into digests</li>
<li>all messages to same addressee are combined into one digest email</li>
<li>digesting only supports text/plain messages</li>
<li>if the digest mail is too big it gets truncated, and full digest is dumped to a file on server; truncated digest will tell about it</li>
<li>the sending itself can be triggered by method call, so now you have options to use ar_sendmail process or smth else, e.g. BackgrounDRB job</li>
<li>you can specify :smtp_settings to be used when sending digests: we needed it to be other than default ActionMailer::Base.smtp_settings</li>
</ul>
<p>Usage example:</p>
<pre class="brush: ruby;">
ActionMailer::ARSendmail.digest_error_emails(
    :dump_path =&gt; '/var/log/myapp',
    :subj_prefix =&gt; ExceptionNotifier.email_prefix,
    :smtp_settings =&gt;   {:address =&gt;     &quot;localhost&quot;,
        :port =&gt;        25,
        :domain =&gt;      'my_domain.com',
        :tls =&gt;          false}
)
</pre>
<p>The fork is contributed by Your Net Works, Inc.</p>
<p><strong>Links:</strong></p>
<ul>
<li> Exception notifier plugin: <a href="http://agilewebdevelopment.com/plugins/exception_notifier">http://agilewebdevelopment.com/plugins/exception_notifier</a></li>
<li> Original ar_mailer gem: <a href="http://seattlerb.rubyforge.org/ar_mailer">http://seattlerb.rubyforge.org/ar_mailer</a></li>
<li> Your Net Works&#8217; fork of ar_mailer: <a href="http://github.com/artemv/ar_mailer">http://github.com/artemv/ar_mailer</a></li>
</ul>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirstydoh.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirstydoh.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirstydoh.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirstydoh.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirstydoh.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirstydoh.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirstydoh.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirstydoh.wordpress.com/37/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirstydoh.wordpress.com/37/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirstydoh.wordpress.com/37/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=37&subd=thirstydoh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thirstydoh.wordpress.com/2009/10/26/error-emails-digesting-ar_mailer-fork/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a40aec85116bcb1ef142fbd8722f88bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thirstydoh</media:title>
		</media:content>
	</item>
		<item>
		<title>Rails template caching in 2.2.2</title>
		<link>http://thirstydoh.wordpress.com/2009/07/31/rails-template-caching-in-2-2-2/</link>
		<comments>http://thirstydoh.wordpress.com/2009/07/31/rails-template-caching-in-2-2-2/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 09:54:07 +0000</pubDate>
		<dc:creator>thirstydoh</dc:creator>
				<category><![CDATA[ActionView]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://thirstydoh.wordpress.com/?p=30</guid>
		<description><![CDATA[Turns out view templates are cached for test environment in Rails 2.2.2, and you can&#8217;t turn it off. This is unfortunate for me because I&#8217;m used to rspeccing with DRB server  &#8211; so now I need to restart it every time I change the view I&#8217;m working on. Bummer.
Good news is that in Rails 2.3 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=30&subd=thirstydoh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Turns out view templates are cached for test environment in Rails 2.2.2, and you can&#8217;t turn it off. This is unfortunate for me because I&#8217;m used to rspeccing with DRB server  &#8211; so now I need to restart it every time I change the view I&#8217;m working on. Bummer.</p>
<p>Good news is that in Rails 2.3 you can turn it off with</p>
<pre>
config.action_view.cache_template_loading = false
</pre>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirstydoh.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirstydoh.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirstydoh.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirstydoh.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirstydoh.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirstydoh.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirstydoh.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirstydoh.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirstydoh.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirstydoh.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=30&subd=thirstydoh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thirstydoh.wordpress.com/2009/07/31/rails-template-caching-in-2-2-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a40aec85116bcb1ef142fbd8722f88bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thirstydoh</media:title>
		</media:content>
	</item>
		<item>
		<title>another attachment_fu hack: partitioning strategy customization</title>
		<link>http://thirstydoh.wordpress.com/2008/10/07/another-attachment_fu-hack-partitioning-strategy-customization/</link>
		<comments>http://thirstydoh.wordpress.com/2008/10/07/another-attachment_fu-hack-partitioning-strategy-customization/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 10:18:54 +0000</pubDate>
		<dc:creator>thirstydoh</dc:creator>
				<category><![CDATA[attachment_fu]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://thirstydoh.wordpress.com/?p=26</guid>
		<description><![CDATA[In attachment_fu you can have attachment file pathes partitioned: uploaded file.jpg goes to files/0000/0167 directory, where 00000167 is internal ID of the file. With this fork you have some control over it:
Now you can specify partitioning strategy as lambda in has_attachment
statement, like this:

    class Attachment &#60; ActiveRecord::Base
      has_attachment :storage =&#62; :file_system, :path_prefix =&#62; 'files/issues',
        :partition [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=26&subd=thirstydoh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In attachment_fu you can have attachment file pathes partitioned: uploaded file.jpg goes to files/0000/0167 directory, where 00000167 is internal ID of the file. With <a href="http://github.com/artemv/attachment_fu/tree/master">this fork</a> you have some control over it:</p>
<p>Now you can specify partitioning strategy as lambda in has_attachment<br />
statement, like this:</p>
<pre class="brush: ruby;">
    class Attachment &lt; ActiveRecord::Base
      has_attachment :storage =&gt; :file_system, :path_prefix =&gt; 'files/issues',
        :partition =&gt; lambda {|a| (a.thumbnail ? a.parent : a).document_id}

      belongs_to :document, :polymorphic =&gt; true
      ...
</pre>
<p>Attachment model object is passed to lambda. In this example we have Issue<br />
model having many Attachments via polymorphic association, and we want<br />
attachment files pathes to be like &#8216;files/issues/67/my_file.doc&#8217;, where 67 is<br />
attachment&#8217;s issue id. The lambda can also return array of strings, then<br />
['a', 'b'] will become path &#8216;files/issues/a/b&#8217; in this case. This lambda will fit<br />
if you use thumbnails; if you don&#8217;t it will be just lambda {|a| a.document_id}.</p>
<p>Note that partitioning is relevant only to :file_system storage.</p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirstydoh.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirstydoh.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirstydoh.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirstydoh.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirstydoh.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirstydoh.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirstydoh.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirstydoh.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirstydoh.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirstydoh.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=26&subd=thirstydoh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thirstydoh.wordpress.com/2008/10/07/another-attachment_fu-hack-partitioning-strategy-customization/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a40aec85116bcb1ef142fbd8722f88bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thirstydoh</media:title>
		</media:content>
	</item>
		<item>
		<title>attachment_fu fork with validation messages customization</title>
		<link>http://thirstydoh.wordpress.com/2008/10/03/attachment_fu-fork-with-validation-messages-customization/</link>
		<comments>http://thirstydoh.wordpress.com/2008/10/03/attachment_fu-fork-with-validation-messages-customization/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 07:00:46 +0000</pubDate>
		<dc:creator>thirstydoh</dc:creator>
				<category><![CDATA[attachment_fu]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://thirstydoh.wordpress.com/?p=19</guid>
		<description><![CDATA[I&#8217;ve just made a fork of attachment_fu plugin: http://github.com/artemv/attachment_fu/tree/master.
This fork provides validation errors customization means.
Now you can pass custom error formatter method names to validates_as_attachment:

validates_as_attachment :error_formatters =&#62; {:content_type =&#62; :add_content_type_error, :size =&#62; :add_size_error}

Here&#8217;s an example of error formatter. It uses Globalize to translate the message template:

    def add_content_type_error(options)
     [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=19&subd=thirstydoh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>I&#8217;ve just made a fork of attachment_fu plugin: <a href="http://github.com/artemv/attachment_fu/tree/master">http://github.com/artemv/attachment_fu/tree/master</a>.</p>
<p>This fork provides validation errors customization means.<br />
Now you can pass custom error formatter method names to validates_as_attachment:</p>
<p><code><br />
validates_as_attachment :error_formatters =&gt; {:content_type =&gt; :add_content_type_error, :size =&gt; :add_size_error}<br />
</code></p>
<p>Here&#8217;s an example of error formatter. It uses Globalize to translate the message template:</p>
<pre class="brush: ruby;">
    def add_content_type_error(options)
      return if !filename #content type doesn't matter if there's no file
      msg = sprintf((&quot;Your file's format (%s) is denied. Allowed are only &quot; +
          &quot;image formats.&quot;).translate, options[:value])

      #don't try to translate string expanded with parameters
      msg.translated = true

      #for it to not mix with attribute name (and break .translated state)
      errors.add_to_base(msg)
    end
</pre>
<p>Also it applies fixes against &#8216;Size is not included in the list error&#8217; issue<br />
(which is often reproduced on Windows) suggested at<br />
<a href="http://railsforum.com/viewtopic.php?pid=26427#p26427">http://railsforum.com/viewtopic.php?pid=26427#p26427</a>.</p>
<p>Short attachment_fu tutorial: <a href="http://clarkware.com/cgi/blosxom/2007/02/24#FileUploadFu">http://clarkware.com/cgi/blosxom/2007/02/24#FileUploadFu</a></p>
  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirstydoh.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirstydoh.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirstydoh.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirstydoh.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirstydoh.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirstydoh.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirstydoh.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirstydoh.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirstydoh.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirstydoh.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=19&subd=thirstydoh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thirstydoh.wordpress.com/2008/10/03/attachment_fu-fork-with-validation-messages-customization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a40aec85116bcb1ef142fbd8722f88bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thirstydoh</media:title>
		</media:content>
	</item>
		<item>
		<title>Formatting diff files as HTML</title>
		<link>http://thirstydoh.wordpress.com/2008/05/24/formatting-diff-files-as-html/</link>
		<comments>http://thirstydoh.wordpress.com/2008/05/24/formatting-diff-files-as-html/#comments</comments>
		<pubDate>Fri, 23 May 2008 21:15:49 +0000</pubDate>
		<dc:creator>thirstydoh</dc:creator>
				<category><![CDATA[codenotifier]]></category>
		<category><![CDATA[diff_to_html.rb]]></category>
		<category><![CDATA[my projects]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://thirstydoh.wordpress.com/?p=18</guid>
		<description><![CDATA[
I wanted to add diff viewing function to my codenotifier tool and all I found in Ruby was this CGI/command line script. I adopted it to show line numbers, handle multifile diffs and make output similar to one of Trac, and integrated it to codenotifier. Plus, in case anybody else needs it, I created diff_to_html.rb [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=18&subd=thirstydoh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a title="codenotifier diff" href="http://www.flickr.com/photos/thirstydog/2518194342/"><img src="http://farm3.static.flickr.com/2307/2518194342_c99a667932_t.jpg" alt="codenotifier diff" width="100" height="77" /></a><br />
I wanted to add diff viewing function to my <a href="http://codenotifier.com">codenotifier</a> tool and all I found in Ruby was <a href="http://gurge.com/blog/2006/10/03/subversion-diff-viewer-cgi-in-ruby">this</a> CGI/command line script. I adopted it to show line numbers, handle multifile diffs and make output similar to one of Trac, and integrated it to codenotifier. Plus, in case anybody else needs it, I created <a href="http://github.com/artemv/diff_to_html.rb/tree/master">diff_to_html.rb</a> opensource project at GitHub (liked it a lot btw!), which makes it available as a gem, like this:</p>
<p><code>gem install artemv-diff_to_html --source=http://gems.github.com</code></p>
<p>Enjoy!</p>
<p>The code is far from being perfect, actually I wonder why it works in some cases, plus it could output better (e.g. I like <a href="http://github.com/artemv/diff_to_html.rb/commit/b386d9f9ca11efda9e7735205411e95020cdceb9#L0R22">changeset viewer</a> at GitHub &#8211; it puts the changes and line numbers in separate DIVs &#8211; this way  you could simply select changes without line numbers.. at price of (sometimes) horizontal scrollbar I guess. The funny thing is that at GitHub result is still mixed with comment counters for each line &#8211; it was so close to being perfect.. as always :)</p>
<p>So, patches/contributions are very welcome.</p>
<p>Related links:</p>
<ul>
<li><a href="http://codenotifier.blogspot.com/2008/05/showing-diffs.html">blog entry</a> on Codenotifier&#8217;s diffs</li>
<li><a href="http://codenotifier.com/projects/38/commits/492">sample diff</a> at Codenotifier, from <a href="http://code.whytheluckystiff.net/shoes/">Shoes</a> project</li>
<li>original code by Adam Doppelt (thanks man!) appears in his <a href="http://gurge.com/blog/2006/10/03/subversion-diff-viewer-cgi-in-ruby">blog entry</a> (blogs became an important source of code, huh?)</li>
<li><a href="http://github.com/artemv/diff_to_html.rb/tree/master">diff_to_html.rb</a> project at GitHub</li>
</ul>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirstydoh.wordpress.com/18/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirstydoh.wordpress.com/18/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirstydoh.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirstydoh.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirstydoh.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirstydoh.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirstydoh.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirstydoh.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirstydoh.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirstydoh.wordpress.com/18/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirstydoh.wordpress.com/18/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirstydoh.wordpress.com/18/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=18&subd=thirstydoh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thirstydoh.wordpress.com/2008/05/24/formatting-diff-files-as-html/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a40aec85116bcb1ef142fbd8722f88bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thirstydoh</media:title>
		</media:content>

		<media:content url="http://farm3.static.flickr.com/2307/2518194342_c99a667932_t.jpg" medium="image">
			<media:title type="html">codenotifier diff</media:title>
		</media:content>
	</item>
		<item>
		<title>reusing templates in ActionMailer</title>
		<link>http://thirstydoh.wordpress.com/2008/04/22/reusing-templates-in-actionmailer/</link>
		<comments>http://thirstydoh.wordpress.com/2008/04/22/reusing-templates-in-actionmailer/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 06:25:17 +0000</pubDate>
		<dc:creator>thirstydoh</dc:creator>
				<category><![CDATA[ActionMailer]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://thirstydoh.wordpress.com/?p=17</guid>
		<description><![CDATA[Well I&#8217;m writing quite a mail-intensive small application right now, and wanted to use the same template for 2 mail actions at some point. Searching for how to use template different from mailer action name didn&#8217;t give results, but looking into the ActionMailer code did (hail the open source!), so I&#8217;m placing it here to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=17&subd=thirstydoh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Well I&#8217;m writing quite a mail-intensive small application right now, and wanted to use the same template for 2 mail actions at some point. Searching for how to use template different from mailer action name didn&#8217;t give results, but looking into the ActionMailer code did (hail the open source!), so I&#8217;m placing it here to be a bit more visible )</p>
<p>Well the solution is quite laconic: just set self.template to what you need, just like you would render :action =&gt; :smth_different in ActionView. In example below enabled_notification action does it:</p>
<pre class="brush: ruby;">
class GroupsMailer &lt; ActionMailer::Base
 #...
 def disabled_notification(group, actor, disabled = true)
    verb = disabled ? 'disabled' : 'enabled'
    subject 'Usergroup \'%s\' was %s' % [group.name, verb]

    body :group =&gt; group, :actor =&gt; actor,
        :group_url =&gt; group_url(group.dn), :verb =&gt; verb

    common_headers(actor)
  end

  def enabled_notification(group, actor)
    disabled_notification(group, actor, false)
    self.template = :disabled_notification
  end
end
</pre>
<p>This was with actionmailer-2.0.1.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirstydoh.wordpress.com/17/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirstydoh.wordpress.com/17/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirstydoh.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirstydoh.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirstydoh.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirstydoh.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirstydoh.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirstydoh.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirstydoh.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirstydoh.wordpress.com/17/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirstydoh.wordpress.com/17/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirstydoh.wordpress.com/17/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=17&subd=thirstydoh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thirstydoh.wordpress.com/2008/04/22/reusing-templates-in-actionmailer/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a40aec85116bcb1ef142fbd8722f88bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thirstydoh</media:title>
		</media:content>
	</item>
		<item>
		<title>routes.rb don&#8217;t require restart</title>
		<link>http://thirstydoh.wordpress.com/2008/02/01/routesrb-dont-require-restart/</link>
		<comments>http://thirstydoh.wordpress.com/2008/02/01/routesrb-dont-require-restart/#comments</comments>
		<pubDate>Thu, 31 Jan 2008 22:06:04 +0000</pubDate>
		<dc:creator>thirstydoh</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://thirstydoh.wordpress.com/?p=16</guid>
		<description><![CDATA[Just noticed that changes to routes.rb doesn&#8217;t require Rails application restart anymore (I&#8217;m on Rails 2.0.1). Cool stuff!
So now we can introduce another named route like this:


map.cloud 'projects/cloud', :controller =&#62; 'projects', :action =&#62; 'cloud'

and then immediately use cloud_url in templates.
Why I wanted to use named route for such a simple case? Actually not because it [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=16&subd=thirstydoh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Just noticed that changes to routes.rb doesn&#8217;t require Rails application restart anymore (I&#8217;m on Rails 2.0.1). Cool stuff!</p>
<p>So now we can introduce another named route like this:</p>
<pre class="brush: ruby;">

map.cloud 'projects/cloud', :controller =&gt; 'projects', :action =&gt; 'cloud'
</pre>
<p>and then immediately use cloud_url in templates.</p>
<p>Why I wanted to use named route for such a simple case? Actually not because it gives nice &#8216;cloud_url&#8217; shortcut. I currently use it in a single place so it dosn&#8217;t matter to me. The reason is that my &#8216;projects&#8217; controller is REST-friendly, i.e. I have &#8216;map.resources :projects&#8217; in routes.rb. So, I have to add some line to routes.rb to use /projects/cloud &#8211; otherwise Rails thinks &#8216;cloud&#8217; is an Id of project I&#8217;m trying to open. So I have 2 options, named route and map.connect, and now the choise is obvious.</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirstydoh.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirstydoh.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirstydoh.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirstydoh.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirstydoh.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirstydoh.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirstydoh.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirstydoh.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirstydoh.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirstydoh.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirstydoh.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirstydoh.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=16&subd=thirstydoh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thirstydoh.wordpress.com/2008/02/01/routesrb-dont-require-restart/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a40aec85116bcb1ef142fbd8722f88bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thirstydoh</media:title>
		</media:content>
	</item>
		<item>
		<title>acts_as_ferret pagination</title>
		<link>http://thirstydoh.wordpress.com/2008/01/17/acts_as_ferret-pagination/</link>
		<comments>http://thirstydoh.wordpress.com/2008/01/17/acts_as_ferret-pagination/#comments</comments>
		<pubDate>Thu, 17 Jan 2008 20:56:13 +0000</pubDate>
		<dc:creator>thirstydoh</dc:creator>
				<category><![CDATA[acts_as_ferret]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[will_paginate]]></category>

		<guid isPermaLink="false">http://thirstydoh.wordpress.com/2008/01/17/acts_as_ferret-pagination/</guid>
		<description><![CDATA[Ok, Ferret is great, but how to paginate?
I saw several solutions on the net and liked this one the most.
It appears that it&#8217;s quite easy to integrate acts_as_ferret with will_paginate, the officially recommended pagination plugin for Rails.
First, a patch is needed. I placed it to a new file in my special place for patches, vendor/plugins/patches/lib; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=15&subd=thirstydoh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Ok, Ferret is great, but how to paginate?</p>
<p>I saw several solutions on the net and liked this one the most.</p>
<p>It appears that it&#8217;s quite easy to integrate <a href="http://projects.jkraemer.net/acts_as_ferret/">acts_as_ferret</a> with <a href="http://rock.errtheblog.com/will_paginate">will_paginate</a>, the officially recommended pagination plugin for Rails.</p>
<p>First, a patch is needed. I placed it to a new file in my special place for patches, vendor/plugins/patches/lib; it could also go in some of existing application files, e.g. bottom of environment.rb:</p>
<pre class="brush: ruby;">

module ActsAsFerret
  module ClassMethods
    alias :find_all_by_contents :find_by_contents
  end
end
</pre>
<p>Then, in controller:</p>
<pre class="brush: ruby;">

@users = User.paginate_by_contents(@search.query,
  :total_entries =&gt; User.total_hits(@search.query), :page =&gt; params[:page],
  :per_page =&gt; 10)</pre>
<p>Change User to your model class here. You can also use sorting here, see Tutorial below for guidelines.</p>
<p>The trick is that will_paginate is friendly to model class&#8217;s methods like find_all_by_xxx; acts_as_ferret&#8217;s   find_by_contents&#8217;s name is a bit wrong for it, so we make an alias, and later this method becomes our model&#8217;s method, when we put acts_as_ferret statement in the model class definition.</p>
<p><b>References:</b></p>
<ul>
<li> Acts_As_Ferret <a href="http://www.railsenvy.com/2007/2/19/acts-as-ferret-tutorial">Tutorial</a></li>
<li>This solution was taken <a href="http://errtheblog.com/posts/47-i-will-paginate">from</a> will_paginate&#8217;s author blog, thanks <span class="highlight"><span>ocher</span>!</span></li>
</ul>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirstydoh.wordpress.com/15/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirstydoh.wordpress.com/15/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirstydoh.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirstydoh.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirstydoh.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirstydoh.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirstydoh.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirstydoh.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirstydoh.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirstydoh.wordpress.com/15/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirstydoh.wordpress.com/15/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirstydoh.wordpress.com/15/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=15&subd=thirstydoh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thirstydoh.wordpress.com/2008/01/17/acts_as_ferret-pagination/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a40aec85116bcb1ef142fbd8722f88bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thirstydoh</media:title>
		</media:content>
	</item>
		<item>
		<title>Adventures with Ferret and unicode strings</title>
		<link>http://thirstydoh.wordpress.com/2008/01/16/adventures-with-ferret-and-unicode-strings/</link>
		<comments>http://thirstydoh.wordpress.com/2008/01/16/adventures-with-ferret-and-unicode-strings/#comments</comments>
		<pubDate>Wed, 16 Jan 2008 16:53:34 +0000</pubDate>
		<dc:creator>thirstydoh</dc:creator>
				<category><![CDATA[ferret]]></category>
		<category><![CDATA[i18n]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://thirstydoh.wordpress.com/2008/01/16/adventures-with-ferret-and-unicode-strings/</guid>
		<description><![CDATA[Ferret is a Lucene port to Ruby. Looks like a very good port. What I like:

 it handles wildcards from both sides of a string (Lucene began to allow prefixing with * not long ago, may be with v2.0),
it has good highlight facility out of the box and that it was very easy to plug [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=14&subd=thirstydoh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p><a href="http://ferret.davebalmain.com/trac">Ferret </a>is a <a href="http://lucene.apache.org/java/docs/">Lucene </a>port to Ruby. Looks like a very good port. What I like:</p>
<ul>
<li> it handles wildcards from both sides of a string (Lucene began to allow prefixing with * not long ago, may be with v2.0),</li>
<li>it has good highlight facility out of the box and that it was very easy to plug into Rails application together with (also great) <a href="http://projects.jkraemer.net/acts_as_ferret/">acts_as_ferret</a> plugin: index dir configuration, population and updating &#8211; all appeared to be automatic, much simpler than using Lucene in Java</li>
<li>acts_as_ferret makes it simple to use index in cluster environment with ferret_server, just start it and it works. Well, almost: I had to patch vendor/plugins/acts_as_ferret/lib/server_manager.rb:</li>
</ul>
<pre class="brush: ruby;">
@@ -35,8 +35,8 @@
begin
ENV['FERRET_USE_LOCAL_INDEX'] = 'true'
ENV['RAILS_ENV'] = $ferret_server_options['environment']
-  #require(File.join(File.dirname(__FILE__), '../../../../config/environment'))
-  require(File.join(File.dirname(ENV['_']), '../config/environment'))
+  require(File.join(File.dirname(__FILE__), '../../../../config/environment'))
+  #require(File.join(File.dirname(ENV['_']), '../config/environment'))
require 'acts_as_ferret'
ActsAsFerret::Remote::Server.new.send($ferret_server_action)
rescue Exception =&gt; e</pre>
<p>What I didn&#8217;t like is that after I thought search was working it appeared that it&#8217;s broken for words with non-latinic symbols. Both on Windows platform where I develop and on Linux where I deploy to. For example, if text contains &#8216;Antônio&#8217; and I search by &#8216;Antônio&#8217; I don&#8217;t find anything; also if I search for &#8216;ant&#8217; I get something like &#8216;Ant??nio&#8217; in results (if highlight is used).More strict example:</p>
<pre class="brush: ruby;">

require 'rubygems'
require 'ferret'

text = &quot;Antônio&quot;
include Ferret::Analysis
tokenizer = StandardAnalyzer.new.token_stream(:field, text)
while token = tokenizer.next
  puts token
end</pre>
<p>The output was:</p>
<p>token["antÃ":0:4:1]<br />
token["nio":5:8:1]</p>
<p>I have some experience with Lucene and know that it handles unicode without problems; Rails is also ok with unicode; the whole situation looked stupid (Ruby being not very unicode-friendly also looks rather stupid but I guess Japanese had some reasons for this &#8211; and I hope 1.9 will be much better) so I decided to dig this problem. Surprisingly I didn&#8217;t find a lot of information on this, it seems that people don&#8217;t really have it. Ok for those unlucky like me here&#8217;s the solution I found.Basically Ferret handles Unicode well out of the box if operating system is not Windows and default locale is Unicode-friendly. Both my environments don&#8217;t satisfy these requirements so I got into not-very-documented troubles.  To resolve them we have to say Ferret some magic words:</p>
<pre class="brush: ruby;">

require 'rubygems'
require 'ferret'

if PLATFORM =~ /win32/
  #strange hack for Windows from Ferret's author to make it unicode-friendly.
  #http://ferret.davebalmain.com/trac/ticket/326#comment:3
  Ferret.locale = ''
else
  #tell Ferret to be unicode-friendly. This unfortunately doesn't work on Windows.
  Ferret.locale = &quot;en_US.UTF-8&quot;
end
puts &quot;failed to set locale&quot; if Ferret.locale.nil?

text = &quot;Antônio&quot;
include Ferret::Analysis
tokenizer = StandardAnalyzer.new.token_stream(:field, text)
while token = tokenizer.next
  puts token
end</pre>
<p>Output on Linux:</p>
<p>token["antônio":0:8:1]</p>
<p>Output on Windows:</p>
<p>token["antгґnio":0:8:1]</p>
<p>Well on Windows that wasn&#8217;t that good but at least it&#8217;s one word so search by &#8216;Antônio&#8217; works.. and in Rails highlight doesn&#8217;t corrupt symbols now.That&#8217;s it!</p>
<p>Versions I used for this article:</p>
<ul>
<li>Ferret 0.11.5</li>
<li>acts_as_ferret 0.4.3 (wow, both start with zeroes)</li>
<li>rails 2.0.1</li>
<li>ruby 1.8.6</li>
</ul>
<p><strong>Update:</strong></p>
<p>Well this solution doesn&#8217;t exactly work on Windows. The test is broken (gives 2 tokens instead of 1) when I set Windows locale (&#8216;Standarts and formats&#8217;) to English; but when it&#8217;s Russian it works fine. Ok, at least that was a stable solution for Linux.</p>
<p><strong>Update:</strong></p>
<p>ferret_server doesn&#8217;t work for Windows, so I cannot use it in my development environment :(</p>
<p>Ruby world pushes me more and more out of Windows :)</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirstydoh.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirstydoh.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirstydoh.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirstydoh.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirstydoh.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirstydoh.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirstydoh.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirstydoh.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirstydoh.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirstydoh.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirstydoh.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirstydoh.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=14&subd=thirstydoh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thirstydoh.wordpress.com/2008/01/16/adventures-with-ferret-and-unicode-strings/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a40aec85116bcb1ef142fbd8722f88bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thirstydoh</media:title>
		</media:content>
	</item>
		<item>
		<title>Markaby you&#8217;re too beautiful</title>
		<link>http://thirstydoh.wordpress.com/2007/12/26/markaby-youre-too-beautiful/</link>
		<comments>http://thirstydoh.wordpress.com/2007/12/26/markaby-youre-too-beautiful/#comments</comments>
		<pubDate>Wed, 26 Dec 2007 20:27:11 +0000</pubDate>
		<dc:creator>thirstydoh</dc:creator>
				<category><![CDATA[markaby]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[templating]]></category>

		<guid isPermaLink="false">http://thirstydoh.wordpress.com/2007/12/26/markaby-youre-too-beautiful/</guid>
		<description><![CDATA[..to resist. The more I write in Rails the more I find myself converting rhtmls to Markaby, another invention of _why&#8217;s genius.

table do
  for project in @projects
    tr.project :id =&#62; &#34;#{project.name}&#34; do
      render :partial =&#62; 'project', :locals =&#62; {:project =&#62; project }
    end
 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=13&subd=thirstydoh&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>..to resist. The more I write in Rails the more I find myself converting rhtmls to <a href="http://redhanded.hobix.com/inspect/markabyForRails.html">Markaby</a>, another invention of <a href="http://whytheluckystiff.net/">_why</a>&#8217;s genius.</p>
<pre class="brush: ruby;">
table do
  for project in @projects
    tr.project :id =&gt; &quot;#{project.name}&quot; do
      render :partial =&gt; 'project', :locals =&gt; {:project =&gt; project }
    end
  end
end
br
link_to 'New project', new_project_url</pre>
<p>The fact that template become a ruby script with all the syntax support from IDE is very powerful also. With conventional IDE I see the scopes of all those container elements like divs.  This is also true for rthml, but not so for HAML which stops me from trying it &#8211;  though it seems to be much more popular rendering engine these days.</p>
<p>The thing that stopped me for a while from using Markaby in all my templates is that forms were usually broken when rendered completely with it. What helped is to write &#8216;form_for&#8217; in some wrapper rhtml and the form body in partial.mab.Now I&#8217;ve learned how to write the form wrapper in Markaby too: this <a href="http://code.whytheluckystiff.net/markaby/ticket/52">ticket</a> has all the answers I need. It&#8217;s a pity the ticket is not resolved: it says it&#8217;s a year old!</p>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/thirstydoh.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/thirstydoh.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thirstydoh.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thirstydoh.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thirstydoh.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thirstydoh.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thirstydoh.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thirstydoh.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thirstydoh.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thirstydoh.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thirstydoh.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thirstydoh.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thirstydoh.wordpress.com&blog=2249341&post=13&subd=thirstydoh&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://thirstydoh.wordpress.com/2007/12/26/markaby-youre-too-beautiful/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a40aec85116bcb1ef142fbd8722f88bb?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thirstydoh</media:title>
		</media:content>
	</item>
	</channel>
</rss>