<?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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Peter Boctor &#187; Ruby &#38; Rails</title>
	<atom:link href="http://peter.boctor.net/category/ruby-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://peter.boctor.net</link>
	<description>Thoughts of a new entrepreneur</description>
	<lastBuildDate>Thu, 02 Feb 2012 22:22:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='peter.boctor.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Peter Boctor &#187; Ruby &#38; Rails</title>
		<link>http://peter.boctor.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://peter.boctor.net/osd.xml" title="Peter Boctor" />
	<atom:link rel='hub' href='http://peter.boctor.net/?pushpress=hub'/>
		<item>
		<title>Excluding build &amp; log folders from TextMate</title>
		<link>http://peter.boctor.net/2010/07/29/excluding-build-log-folders-from-textmate/</link>
		<comments>http://peter.boctor.net/2010/07/29/excluding-build-log-folders-from-textmate/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 23:26:59 +0000</pubDate>
		<dc:creator>Peter Boctor</dc:creator>
				<category><![CDATA[iPhoneDev]]></category>
		<category><![CDATA[Ruby & Rails]]></category>

		<guid isPermaLink="false">http://peter.boctor.net/?p=176</guid>
		<description><![CDATA[How many times have you done a Find in Project (Command-Shift-F) in TextMate and accidentally searched through your Rails development.log or your Xcode build files? TextMate tries to read these massive files and your whole machine grinds to a halt. I finally got tired of this and figured out how to configure TextMate to automatically [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peter.boctor.net&amp;blog=2620782&amp;post=176&amp;subd=peterboctor&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>How many times have you done a Find in Project (Command-Shift-F) in TextMate and accidentally searched through your Rails development.log or your Xcode build files?</p>
<p>TextMate tries to read these massive files and your whole machine grinds to a halt. I finally got tired of this and figured out how to configure TextMate to automatically ignore these folders.</p>
<p>Go to TextMate&#8217;s Preferences -&gt; Advanced -&gt; Folder Pattern</p>
<p>Replace this default pattern:<br />
!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</p>
<p>with this pattern that adds an exclusion for folders named &#8216;build&#8217;or &#8216;log&#8217;:<br />
!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))|build|log$</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peterboctor.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peterboctor.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/peterboctor.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/peterboctor.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/peterboctor.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/peterboctor.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/peterboctor.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/peterboctor.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/peterboctor.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/peterboctor.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/peterboctor.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/peterboctor.wordpress.com/176/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/peterboctor.wordpress.com/176/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/peterboctor.wordpress.com/176/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peter.boctor.net&amp;blog=2620782&amp;post=176&amp;subd=peterboctor&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peter.boctor.net/2010/07/29/excluding-build-log-folders-from-textmate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dfad456f9e0753a53eeea065a06ddbdd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pboctor</media:title>
		</media:content>
	</item>
		<item>
		<title>Rails Views &amp; Helpers</title>
		<link>http://peter.boctor.net/2007/05/25/rails-views-helpers/</link>
		<comments>http://peter.boctor.net/2007/05/25/rails-views-helpers/#comments</comments>
		<pubDate>Fri, 25 May 2007 23:07:32 +0000</pubDate>
		<dc:creator>Peter Boctor</dc:creator>
				<category><![CDATA[Ruby & Rails]]></category>

		<guid isPermaLink="false">http://peter.boctor.net/2007/05/25/rails-views-helpers/</guid>
		<description><![CDATA[Inspired by DRY up your views (slides) at last week&#8217;s RailsConf, I&#8217;m trying to improve a view that contains far too much code. The view needs to display a menu of tasks. Whether and how each task is displayed depends on a combination of the current user&#8217;s rights as well as what they had done [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peter.boctor.net&amp;blog=2620782&amp;post=13&amp;subd=peterboctor&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Inspired by <a href="http://conferences.oreillynet.com/cs/rails2007/view/e_sess/12335">DRY up your views</a> (<a href="http://conferences.oreillynet.com/presentations/rails2007/VisForVexing.pdf">slides</a>) at last week&#8217;s <a href="http://conferences.oreillynet.com/rails/">RailsConf</a>, I&#8217;m trying to improve a view that contains far too much code.</p>
<p>The view needs to display a menu of tasks. Whether and how each task is displayed depends on a combination of the current user&#8217;s rights as well as what they had done previously.</p>
<p>With a big block of code for each task, the view file quickly became a mess:</p>
<p><code><br />
&lt;div&gt;<br />
&nbsp;&nbsp;&lt;ul&nbsp;class='menu'&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;%&nbsp;if&nbsp;current_user.has_right_for?('foos')&nbsp;%&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;%&nbsp;if&nbsp;current_user.foo&nbsp;%&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;%=&nbsp;link_to&nbsp;'Stop&nbsp;Foo',&nbsp;foo_url,&nbsp;:method&nbsp;=&gt;&nbsp;:delete&nbsp;%&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;%&nbsp;else&nbsp;%&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;%&nbsp;form_tag(foos_url,&nbsp;:name=&gt;'add_foo',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:style=&gt;&quot;margin:0;padding:0;display:inline;&quot;)&nbsp;do&nbsp;%&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;%=&nbsp;hidden_field_tag&nbsp;:bar_id,&nbsp;@bar.id&nbsp;%&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;%=&nbsp;link_to_function&nbsp;&quot;Start&nbsp;Foo&quot;,&nbsp;&quot;document.add_foo.submit()&quot;&nbsp;%&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;%&nbsp;end&nbsp;%&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;%&nbsp;end&nbsp;%&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/li&gt;<br />
&nbsp;&nbsp;&lt;/ul&gt;<br />
&lt;/div&gt;<br />
</code></p>
<p>OK, so let&#8217;s move each task into a helper:<br />
<code><br />
&lt;div&gt;<br />
&nbsp;&nbsp;&lt;ul&nbsp;class='menu'&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;%=&nbsp;start_or_stop_foo&nbsp;-%&gt;<br />
&nbsp;&nbsp;&lt;/ul&gt;<br />
&lt;/div&gt;</p>
<p>def&nbsp;start_or_stop_foo(tag='li')<br />
&nbsp;&nbsp;if&nbsp;current_user.has_right_for?('foos')<br />
&nbsp;&nbsp;&nbsp;&nbsp;content_tag(tag,&nbsp;link_to('Stop&nbsp;Foo',&nbsp;foo_url,&nbsp;:method&nbsp;=&gt;&nbsp;:delete))<br />
&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;content_tag(tag)&nbsp;do<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;form_tag(foos_url,&nbsp;:name=&gt;'add_foo',<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:style=&gt;&quot;margin:0;padding:0;display:inline;&quot;)&nbsp;do<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hidden_field_tag&nbsp;:bar_id,&nbsp;@bar.id<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;link_to_function&nbsp;&quot;Start&nbsp;Foo&quot;,&nbsp;&quot;document.add_foo.submit()&quot;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br />
&nbsp;&nbsp;&nbsp;&nbsp;end<br />
&nbsp;&nbsp;end<br />
end<br />
</code></p>
<p>This unfortunately doesn&#8217;t work. Both content_tag and form_tag assume that you&#8217;re calling them from an action view template. A <a href="http://dev.rubyonrails.org/ticket/7857">fix</a> has been applied to edge rails for content_tag, but we need one for form_tag:</p>
<p>From form_tag_helper.rb, replace:<br />
<code><br />
concat(tag(:form,&nbsp;html_options,&nbsp;true)&nbsp;+&nbsp;method_tag,&nbsp;block.binding)<br />
concat(content,&nbsp;block.binding)<br />
concat(&quot;&lt;/form&gt;&quot;,&nbsp;block.binding)<br />
</code><br />
with:<br />
<code><br />
form_tag&nbsp;=&nbsp;tag(:form,&nbsp;html_options,&nbsp;true)&nbsp;+&nbsp;method_tag<br />
if&nbsp;block_is_within_action_view?(block)<br />
&nbsp;&nbsp;concat(form_tag,&nbsp;block.binding)<br />
&nbsp;&nbsp;concat(content,&nbsp;block.binding)<br />
&nbsp;&nbsp;concat(&quot;&lt;/form&gt;&quot;,&nbsp;block.binding)<br />
else<br />
&nbsp;&nbsp;form_tag&nbsp;+&nbsp;content&nbsp;+&nbsp;&quot;&lt;/form&gt;&quot;<br />
end</p>
<p>def&nbsp;block_is_within_action_view?(block)&nbsp;<br />
&nbsp;&nbsp;eval(&quot;defined?&nbsp;_erbout&quot;,&nbsp;block.binding)&nbsp;<br />
end<br />
</code></p>
<p>I don&#8217;t like patching Rails because it&#8217;s fragile. I have to remember to remove or re-apply the patch the next time I upgrade my Rails installation.</p>
<p>Is there another way of moving this code out of the view and into a helper?</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/peterboctor.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/peterboctor.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/peterboctor.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/peterboctor.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/peterboctor.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/peterboctor.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/peterboctor.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/peterboctor.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/peterboctor.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/peterboctor.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/peterboctor.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/peterboctor.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/peterboctor.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/peterboctor.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/peterboctor.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/peterboctor.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=peter.boctor.net&amp;blog=2620782&amp;post=13&amp;subd=peterboctor&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://peter.boctor.net/2007/05/25/rails-views-helpers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/dfad456f9e0753a53eeea065a06ddbdd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">pboctor</media:title>
		</media:content>
	</item>
	</channel>
</rss>
