<?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/"
	>

<channel>
	<title>Wirestorm &#187; Ruby on Rails</title>
	<atom:link href="http://wirestorm.net/blog/category/ruby-on-rails/feed/?category_name=ruby-on-rails" rel="self" type="application/rss+xml" />
	<link>http://wirestorm.net/blog</link>
	<description>Ray Hilton&#039;s blog about interesting technology</description>
	<lastBuildDate>Mon, 12 Dec 2011 11:07:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2-bleeding</generator>
		<item>
		<title>Criteria for ActiveRecord</title>
		<link>http://wirestorm.net/blog/2008/04/06/criteria-for-activerecord/</link>
		<comments>http://wirestorm.net/blog/2008/04/06/criteria-for-activerecord/#comments</comments>
		<pubDate>Sun, 06 Apr 2008 08:00:39 +0000</pubDate>
		<dc:creator>rayh</dc:creator>
				<category><![CDATA[Criteria]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://wirestorm.net/blog/?p=53</guid>
		<description><![CDATA[Over the last couple of days I&#8217;ve been working on a Criteria for ActiveRecord. The concept is quite simple; rather than writing strings of SQL to pass to the find() method, we build the criteria using an object-orientated approach. Anyone who has used Hibernate, Torque, Propel et al will know how powerful and useful this [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last couple of days I&#8217;ve been working on a Criteria for ActiveRecord.  The concept is quite simple; rather than writing strings of SQL to pass to the find() method, we build the criteria using an object-orientated approach.  Anyone who has used Hibernate, Torque, Propel et al will know how powerful and useful this can be.  </p>
<p>For example, imagine you have a series of filters, all of which may, or may not, add constraints or expressions to your query.  Each filter will need to append it&#8217;s own SQL to the end of any previously generated SQL and may even need to introspect the existing SQL to determine if its doubling up on statements or resolve potential conflicts.</p>
<p>With Criteria this becomes simpler.  For example:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">criteria = Criteria.<span style="color:#9900CC;">new</span>
criteria.<span style="color:#9966CC; font-weight:bold;">and</span> <span style="color:#9966CC; font-weight:bold;">do</span> |c|
  c.<span style="color:#9966CC; font-weight:bold;">or</span> User.<span style="color:#9900CC;">role</span>.<span style="color:#9900CC;">eq</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:admin</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  c.<span style="color:#9966CC; font-weight:bold;">or</span> User.<span style="color:#9900CC;">active</span>.<span style="color:#9900CC;">eq</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">false</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  c.<span style="color:#9966CC; font-weight:bold;">or</span> User.<span style="color:#9900CC;">createdAt</span>.<span style="color:#9900CC;">gt</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">10</span>.<span style="color:#9900CC;">hours</span>.<span style="color:#9900CC;">ago</span><span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
criteria.<span style="color:#9966CC; font-weight:bold;">and</span> <span style="color:#9966CC; font-weight:bold;">do</span> |c|
  c.<span style="color:#9966CC; font-weight:bold;">or</span> User.<span style="color:#9900CC;">role</span>.<span style="color:#9900CC;">eq</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:editor</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  c.<span style="color:#9966CC; font-weight:bold;">or</span> User.<span style="color:#9900CC;">active</span>.<span style="color:#9900CC;">eq</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  c.<span style="color:#9966CC; font-weight:bold;">or</span> <span style="color:#9966CC; font-weight:bold;">do</span> |c2|
    c2.<span style="color:#9966CC; font-weight:bold;">and</span> User.<span style="color:#9900CC;">createdAt</span>.<span style="color:#9900CC;">gt</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">20</span>.<span style="color:#9900CC;">days</span>.<span style="color:#9900CC;">ago</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    c2.<span style="color:#9966CC; font-weight:bold;">and</span> User.<span style="color:#9900CC;">createdAt</span>.<span style="color:#9900CC;">lt</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">10</span>.<span style="color:#9900CC;">hours</span>.<span style="color:#9900CC;">ago</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
users = User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:all</span>, criteria<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>We could, at any point, introspect the state of criteria by calling:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">criteria.<span style="color:#9900CC;">ands</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |c|
  put <span style="color:#996600;">&quot;AND #{c}&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
criteria.<span style="color:#9900CC;">ors</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |c|
  put <span style="color:#996600;">&quot;OR #{c}&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And, finally, we can remove arbitrary bits of criteria:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby">criteria.<span style="color:#9900CC;">ands</span>.<span style="color:#9900CC;">delete_at</span> <span style="color:#006666;">2</span></pre></div></div>

<p>I hope to have a release out very soon, but for the time being some more examples and API docs are  on the <a href="http://criteria.rubyforge.org/">Criteria project page</a> on <a href="http://rubyforge.org">RubyForge</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wirestorm.net/blog/2008/04/06/criteria-for-activerecord/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse + PHP + J2EE + Rails</title>
		<link>http://wirestorm.net/blog/2007/07/04/eclipse-php-j2ee-rails/</link>
		<comments>http://wirestorm.net/blog/2007/07/04/eclipse-php-j2ee-rails/#comments</comments>
		<pubDate>Wed, 04 Jul 2007 02:33:42 +0000</pubDate>
		<dc:creator>rayh</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Howto]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://wirestorm.net/blog/?p=47</guid>
		<description><![CDATA[I have just decided to upgrade Eclipse, and thought it best to start from scratch. I do a lot of work in Java, PHP as well as Ruby on Rails and so I tried to set up an integrated environment using Eclipse. I have documented the steps here as much as a reminder for myself [...]]]></description>
			<content:encoded><![CDATA[<p>I have just decided to upgrade Eclipse, and thought it best to start from scratch.  I do a lot of work in Java, PHP as well as Ruby on Rails and so I tried to set up an integrated environment using Eclipse.  I have documented the steps here as much as a reminder for myself as a guide for other people trying to something similar.</p>
<p>First, download and unzip the Ecipse + J2EE package from <a href="http://www.eclipse.org/downloads/">http://www.eclipse.org/downloads/</a>.  You do not need to &#8216;install&#8217; Eclipse as such, just put the uncompressed directory somewhere logical (/Applications on a Mac, for example).<a href="http://www.eclipse.org/downloads/">
</a></p>
<ol>
<li>Launch Eclipse <img src='http://wirestorm.net/blog/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </li>
<li>Select: <strong>Help</strong> -> <strong>Software Update</strong> -> <strong>Final and Install</strong>.</li>
<li>Select  <strong>Search for new features to install</strong></li>
<li>Check the <strong>Europa Discovery Service</strong></li>
<li>Select<strong> Add Remote Site</strong></li>
</ol>
<ol>
<li>Type in name:<strong> Aptana </strong>(For javascript support)</li>
<li>Type in url: <strong>http://update.aptana.com/install/3.2/</strong></li>
<li>Select <strong>OK
</strong></li>
</ol>
<li>Select<strong> </strong><strong>Add Remote Site</strong> (For Ruby on Rails support)<strong>
</strong></p>
<ol>
<li>Type in name:<strong> RadRails</strong></li>
<li>Type in url:<strong> http://update.aptana.com/install/rails/3.2/</strong></li>
<li>Select<strong> OK</strong></li>
</ol>
</li>
<li>Select<strong> Add Remote Site </strong>(For SVN integration)
<ol>
<li>Type in name: <strong>Subclipse</strong></li>
<li>Type in url:<strong> http://subclipse.tigris.org/update_1.2.x</strong></li>
<li>Select<strong> OK</strong></li>
</ol>
</li>
<li>Select<strong> Add Remote Site</strong> (for PHP support)<strong>
</strong></p>
<ol>
<li>Type in name: <strong>PDT</strong></li>
<li>Type in url:<strong> http://download.eclipse.org/tools/pdt/updates/</strong></li>
<li>Select<strong> OK</strong></li>
</ol>
</li>
<li>Select<strong> Add Remove Site </strong>(for Hibernate support)
<ol>
<li>Type in name:<strong> Hibernate Tools</strong></li>
<li>Type in url:<strong> http://download.jboss.org/jbosside/updates/development</strong></li>
<li>Select<strong> OK
</strong></li>
</ol>
</li>
<li>Select <strong>Finish</strong></li>
<li>Select your nearest mirror, when prompted</li>
<li>Select <strong>Eurpoa Discovery Site</strong> -> <strong>Programming Languages</strong> -> <strong>Ruby Development Tools</strong></li>
<li>Select <strong>PDT</strong></li>
<li>Select <strong>Aptana</strong></li>
<li>Select <strong>RadRails</strong></li>
<li>Select <strong>Subclipse</strong></li>
<li>Select<strong> Hibernate Tools
</strong></li>
<li>Select <strong>Select Required</strong> (to resolve dependencies)</li>
<li>Select <strong>Next</strong></li>
<li>Accept the agreement(s) and <strong>select Next</strong></li>
<li>Select <strong>Finish</strong></li>
<li>Go for a walk.</li>
<p>Phew, so after all that, you should have an Eclipse IDE set up to support PHP, Ruby, Rails, Javascript, Java, Hibernate and  Subversion.  You can, of course, select many other tools from the Europa discovery site for other development tools, graphical editing and the like.</p>
]]></content:encoded>
			<wfw:commentRss>http://wirestorm.net/blog/2007/07/04/eclipse-php-j2ee-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

