<?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>Cory O&#039;Daniel - These are just words &#187; datamapper</title>
	<atom:link href="http://coryodaniel.com/index.php/category/software/datamapper-software/feed/" rel="self" type="application/rss+xml" />
	<link>http://coryodaniel.com</link>
	<description>Software development, thoughts, and randomness</description>
	<lastBuildDate>Thu, 17 Nov 2011 21:18:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>DataMapper 0.10+ Basic Sphinx Support</title>
		<link>http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/</link>
		<comments>http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 22:18:26 +0000</pubDate>
		<dc:creator>Cory O'Daniel</dc:creator>
				<category><![CDATA[RubyDevelopment]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[sphinx]]></category>

		<guid isPermaLink="false">http://coryodaniel.com/?p=415</guid>
		<description><![CDATA[I needed sphinx support and I needed it now. Apparently dm-sphinx-adapter wasn't ported to dm 0.10.  I started porting it, but I kind of felt like I was going down a rabbit whole.  I will continue to work on it over the next couple days, in the meantime at Vokle we used this [...]]]></description>
			<content:encoded><![CDATA[<p>I needed sphinx support and I needed it now. Apparently dm-sphinx-adapter wasn't ported to dm 0.10.  I started porting it, but I kind of felt like I was going down a rabbit whole.  I will continue to work on it over the next couple days, in the meantime at Vokle we used this to get our fulltext on. Note, this is doing the fulltext search across all columns in your fulltext index.  Its not doing cool matchers like :updated_at.gt yada-yada.  It also doesn't implement a DataMapper Adapter, its a super hack, but it gets the job done for us.</p>
<p>Give me your two cents and stay tuned for a full blown adapter.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">module</span> DataMapper
  <span style="color:#9966CC; font-weight:bold;">module</span> Model
    <span style="color:#9966CC; font-weight:bold;">def</span> sphinx_setup<span style="color:#006600; font-weight:bold;">&#40;</span>opts=<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0066ff; font-weight:bold;">@_sphinx_index</span> = opts<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:index</span><span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> search<span style="color:#006600; font-weight:bold;">&#40;</span>_query_, opts=<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      sph_client = opts.<span style="color:#9900CC;">delete</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:client</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#6666ff; font-weight:bold;">Riddle::Client</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">*</span>SimpleSphinx.<span style="color:#9900CC;">conf</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      sph_client.<span style="color:#9900CC;">match_mode</span> = opts.<span style="color:#9900CC;">delete</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:match_mode</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#ff3333; font-weight:bold;">:extended</span>
&nbsp;
      sphinx_query = _query_.<span style="color:#9900CC;">to_s</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#91;</span>\<span style="color:#006600; font-weight:bold;">&#40;</span>\<span style="color:#006600; font-weight:bold;">&#41;</span>\<span style="color:#006600; font-weight:bold;">|</span>\<span style="color:#006600; font-weight:bold;">-</span>!@~<span style="color:#996600;">&quot;&amp;<span style="color:#000099;">\/</span>]/){|char| &quot;</span>\\<span style="color:#008000; font-style:italic;">#{char}&quot;}</span>
&nbsp;
      results   = sph_client.<span style="color:#9900CC;">query</span><span style="color:#006600; font-weight:bold;">&#40;</span>sphinx_query, <span style="color:#0066ff; font-weight:bold;">@_sphinx_index</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">storage_names</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:default</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">to_sym</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      matches   = results<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:matches</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      ids       = matches.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">|</span>match<span style="color:#006600; font-weight:bold;">|</span> match<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:doc</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># Fetch</span>
      <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">all</span><span style="color:#006600; font-weight:bold;">&#40;</span>opts.<span style="color:#9900CC;">merge</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span>:id <span style="color:#006600; font-weight:bold;">=&gt;</span> ids<span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</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>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> SimpleSphinx
  <span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#0000FF; font-weight:bold;">self</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> conf
      <span style="color:#006600; font-weight:bold;">&#91;</span>server, port<span style="color:#006600; font-weight:bold;">&#93;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> server=<span style="color:#006600; font-weight:bold;">&#40;</span>s<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0066ff; font-weight:bold;">@_server</span> = s
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> port=<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">p</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#0066ff; font-weight:bold;">@_port</span> = <span style="color:#CC0066; font-weight:bold;">p</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> server
      <span style="color:#0066ff; font-weight:bold;">@_server</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#996600;">'localhost'</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> port
      <span style="color:#0066ff; font-weight:bold;">@_port</span> <span style="color:#006600; font-weight:bold;">||</span> <span style="color:#006666;">3312</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Wanna use it?</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Your Model here</span>
Person.<span style="color:#9900CC;">sphinx_setup</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:index</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;indexName&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;">#defaults to storage name</span>
SimpleSphinx.<span style="color:#9900CC;">server</span> = <span style="color:#996600;">&quot;example.com&quot;</span>
SimpleSphinx.<span style="color:#9900CC;">port</span> = <span style="color:#006666;">3312</span>
&nbsp;
Person.<span style="color:#9900CC;">search</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;cory&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#008000; font-style:italic;">#=&gt; DataMapper::Collection</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># you can pass an additional hash of stuff you would pass to Model#all and this will be used to filter</span>
<span style="color:#008000; font-style:italic;"># the result set down POST sphinx when its collecting data from datamapper</span>
Person.<span style="color:#9900CC;">search</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;cory&quot;</span>, <span style="color:#ff3333; font-weight:bold;">:limit</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">10</span>, <span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:male</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>You've got your sphinxter back. Congrats!</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=DataMapper+0.10%2B+Basic+Sphinx+Support+http://coryodaniel.com/?p=415" title="Post to Twitter"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/&amp;title=DataMapper+0.10%2B+Basic+Sphinx+Support" title="Post to Digg"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-digg-big2.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/&amp;t=DataMapper+0.10%2B+Basic+Sphinx+Support" title="Post to Facebook"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-facebook-big2.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/&amp;title=DataMapper+0.10%2B+Basic+Sphinx+Support" title="Post to Reddit"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-reddit-big2.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/&amp;title=DataMapper+0.10%2B+Basic+Sphinx+Support" title="Post to StumbleUpon"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-su-big2.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://coryodaniel.com/index.php/2010/01/07/datamapper-0-10-basic-sphinx-support/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DataMapper and Merb, sharing your errors via the merb display API.</title>
		<link>http://coryodaniel.com/index.php/2009/12/30/datamapper-and-merb-sharing-your-errors-via-the-merb-display-api/</link>
		<comments>http://coryodaniel.com/index.php/2009/12/30/datamapper-and-merb-sharing-your-errors-via-the-merb-display-api/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 00:29:20 +0000</pubDate>
		<dc:creator>Cory O'Daniel</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[RubyDevelopment]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[display api]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://coryodaniel.com/?p=388</guid>
		<description><![CDATA[This is a quick little snippet.  At Vokle all of our products are built using our core API, which thanks to merb, was a piece of cake. The thing that sucks is sometimes we return objects as JSON via the display API and the "errors" are missing in the event that validation failed.  [...]]]></description>
			<content:encoded><![CDATA[<p>This is a quick little snippet.  At Vokle all of our products are built using our core API, which thanks to merb, was a piece of cake. The thing that sucks is sometimes we return objects as JSON via the display API and the "errors" are missing in the event that validation failed.  How to fix that?</p>
<p>Throw this somewhere:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">module</span> DataMapper
  <span style="color:#9966CC; font-weight:bold;">module</span> Validate
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">class</span> ValidationErrors
      <span style="color:#9966CC; font-weight:bold;">def</span> to_json
        <span style="color:#0066ff; font-weight:bold;">@errors</span>.<span style="color:#9900CC;">to_hash</span>.<span style="color:#9900CC;">to_json</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Now in your merb controllers, when you are displaying an object that may have errors:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> People <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">Merb::Controller</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> create<span style="color:#006600; font-weight:bold;">&#40;</span>person<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#008000; font-style:italic;">#... *SNIP* ...</span>
    display <span style="color:#0066ff; font-weight:bold;">@person</span>, <span style="color:#0000FF; font-weight:bold;">nil</span>, <span style="color:#006600; font-weight:bold;">&#123;</span>:methods <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:errors</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
    <span style="color:#008000; font-style:italic;">#... *SNIP* ...</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>And whatever is getting your data back in XML or JSON (yeah or YAML, right) will get the errors on your object as well.  Cool.</p>
<p>Yay, users give you invalid data. Congrats.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=DataMapper+and+Merb%2C+sharing+your+errors+via+the+merb+display+API.+http://coryodaniel.com/?p=388" title="Post to Twitter"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://coryodaniel.com/index.php/2009/12/30/datamapper-and-merb-sharing-your-errors-via-the-merb-display-api/&amp;title=DataMapper+and+Merb%2C+sharing+your+errors+via+the+merb+display+API." title="Post to Digg"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-digg-big2.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://coryodaniel.com/index.php/2009/12/30/datamapper-and-merb-sharing-your-errors-via-the-merb-display-api/&amp;t=DataMapper+and+Merb%2C+sharing+your+errors+via+the+merb+display+API." title="Post to Facebook"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-facebook-big2.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://coryodaniel.com/index.php/2009/12/30/datamapper-and-merb-sharing-your-errors-via-the-merb-display-api/&amp;title=DataMapper+and+Merb%2C+sharing+your+errors+via+the+merb+display+API." title="Post to Reddit"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-reddit-big2.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://coryodaniel.com/index.php/2009/12/30/datamapper-and-merb-sharing-your-errors-via-the-merb-display-api/&amp;title=DataMapper+and+Merb%2C+sharing+your+errors+via+the+merb+display+API." title="Post to StumbleUpon"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-su-big2.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://coryodaniel.com/index.php/2009/12/30/datamapper-and-merb-sharing-your-errors-via-the-merb-display-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DM Cutie, et al. 0.4 release (minor updates)</title>
		<link>http://coryodaniel.com/index.php/2009/12/30/dm-cutie-et-al-0-4-release-minor-updates/</link>
		<comments>http://coryodaniel.com/index.php/2009/12/30/dm-cutie-et-al-0-4-release-minor-updates/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 19:12:48 +0000</pubDate>
		<dc:creator>Cory O'Daniel</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[dm-cutie]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://coryodaniel.com/?p=347</guid>
		<description><![CDATA[I released dm-cutie, dm-cutie-ui, and dm-cutie-extras with some minor releases on gemcutter.org today.
The minor updates include a lot of help information and some tweaks to dm-cutie-ui to make it easier to use/understand (I hope).
+ add 'help' area describing all the default views
+ MysqlIndex/ Steps column info in help
+ Sort Tables Repo, Gen, Executed, Others by [...]]]></description>
			<content:encoded><![CDATA[<p>I released <a href="http://github.com/coryodaniel/dm-cutie">dm-cutie</a>, <a href="http://github.com/coryodaniel/dm-cutie">dm-cutie-ui</a>, and <a href="http://github.com/coryodaniel/dm-cutie">dm-cutie-extras</a> with some minor releases on gemcutter.org today.</p>
<p>The minor updates include a lot of help information and some tweaks to dm-cutie-ui to make it easier to use/understand (I hope).<br />
+ add 'help' area describing all the default views<br />
+ MysqlIndex/ Steps column info in help<br />
+ Sort Tables Repo, Gen, Executed, Others by alpha (routes key should be view_name)<br />
+ menu cleanup<br />
+ @records count on page<br />
+ Moved connected to<br />
+ Changed word on relationship link<br />
+ Format of page title<br />
+ Removed duplicate column on mysql_index<br />
+ Sort buttons moved</p>
<p>If you haven't installed DM Cutie, make sure your rubygems is up to date and do:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> gemcutter <span style="color: #660033;">--source</span> http:<span style="color: #000000; font-weight: bold;">//</span>gemcutter.org
gem tumble
gem <span style="color: #c20cb9; font-weight: bold;">install</span> dm-cutie <span style="color: #660033;">-v</span> 0.4.0
gem <span style="color: #c20cb9; font-weight: bold;">install</span> dm-cutie-ui <span style="color: #660033;">-v</span> 0.4.0
gem <span style="color: #c20cb9; font-weight: bold;">install</span> dm-cutie-extras <span style="color: #660033;">-v</span> 0.4.0</pre></td></tr></table></div>

<p>Information on setting DM Cutie up is in <a href="http://coryodaniel.com/index.php/2009/11/25/datamapper-cutie-the-query-tracker-and-profiler/">this post</a>.</p>
<p>If you want the source its available on <a href="http://github.com/coryodaniel">my github page.</a></p>
<p>I'll be adding some more interesting tracking stuff for MySQL in the next few days. Now that <a href="http://vokle.com">Vokle</a> has officially launched, I find myself with more time to work on my projects.</p>
<p>When I started this project I really wanted it to be a cool way to get information on <i>all</i> your DM storage needs. I am now realizing that DM Cutie should probably only support SQL and DO backed stores, and I'll be pairing down the internals over the next few days with that in mind.</p>
<p>Most of my database experience as far as optimizing goes is in MySQL, if anyone has some PostgreSQL or SQlite awesomeness they'd like to share, I'd really appreciate it.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=DM+Cutie%2C+et+al.+0.4+release+%28minor+updates%29+http://coryodaniel.com/?p=347" title="Post to Twitter"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://coryodaniel.com/index.php/2009/12/30/dm-cutie-et-al-0-4-release-minor-updates/&amp;title=DM+Cutie%2C+et+al.+0.4+release+%28minor+updates%29" title="Post to Digg"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-digg-big2.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://coryodaniel.com/index.php/2009/12/30/dm-cutie-et-al-0-4-release-minor-updates/&amp;t=DM+Cutie%2C+et+al.+0.4+release+%28minor+updates%29" title="Post to Facebook"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-facebook-big2.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://coryodaniel.com/index.php/2009/12/30/dm-cutie-et-al-0-4-release-minor-updates/&amp;title=DM+Cutie%2C+et+al.+0.4+release+%28minor+updates%29" title="Post to Reddit"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-reddit-big2.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://coryodaniel.com/index.php/2009/12/30/dm-cutie-et-al-0-4-release-minor-updates/&amp;title=DM+Cutie%2C+et+al.+0.4+release+%28minor+updates%29" title="Post to StumbleUpon"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-su-big2.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://coryodaniel.com/index.php/2009/12/30/dm-cutie-et-al-0-4-release-minor-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DataMapper Cutie &#8211; The query tracker and profiler</title>
		<link>http://coryodaniel.com/index.php/2009/11/25/datamapper-cutie-the-query-tracker-and-profiler/</link>
		<comments>http://coryodaniel.com/index.php/2009/11/25/datamapper-cutie-the-query-tracker-and-profiler/#comments</comments>
		<pubDate>Thu, 26 Nov 2009 02:05:02 +0000</pubDate>
		<dc:creator>Cory O'Daniel</dc:creator>
				<category><![CDATA[RubyDevelopment]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[dm-cutie]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://statics.coryodaniel.com/?p=339</guid>
		<description><![CDATA[So Ive been busting my butt on this query tracker for a while now. Its been finished twice and not released (once when I hated the API, and once right before 0.10 was release). But here she is, open for the hacking.
Its pretty easy to get set up, the gems are on http://gemcutter.org
To get started:

1
2
3
4
5
6
7
8
$ [...]]]></description>
			<content:encoded><![CDATA[<p>So Ive been busting my butt on this query tracker for a while now. Its been finished twice and not released (once when I hated the API, and once right before 0.10 was release). But here she is, open for the hacking.</p>
<p>Its pretty easy to get set up, the gems are on http://gemcutter.org</p>
<p>To get started:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">$ gem sources <span style="color:#006600; font-weight:bold;">-</span>a http:<span style="color:#006600; font-weight:bold;">//</span>gemcutter.<span style="color:#9900CC;">org</span> <span style="color:#008000; font-style:italic;"># Add gem cutter to your gem sources</span>
$ gem install dm<span style="color:#006600; font-weight:bold;">-</span>cutie
&nbsp;
<span style="color:#008000; font-style:italic;"># This is a plugin pack for dm-cutie</span>
$ gem install dm<span style="color:#006600; font-weight:bold;">-</span>cutie<span style="color:#006600; font-weight:bold;">-</span>extras 
&nbsp;
<span style="color:#008000; font-style:italic;"># this is the front-end to dm-cutie</span>
$ gem install dm<span style="color:#006600; font-weight:bold;">-</span>cutie<span style="color:#006600; font-weight:bold;">-</span>ui</pre></td></tr></table></div>

<p>If you plan to use MySQL to store dm-cuties information, set up a schema for that now by doing:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">mysql: CREATE SCHEMA <span style="color: #000000; font-weight: bold;">`</span>dm_cutie<span style="color: #000000; font-weight: bold;">`</span>;</pre></td></tr></table></div>

<p>dm-cutie will allow you to store stuff across different adapters, so you can actually profile a Mysql DataMapper Repository into a dm-cutie sqlite3 repository.  Its ok, she gets it</p>
<p>Now, in your application after your default DataMapper repository is set up do:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'dm-cutie'</span>
 <span style="color:#008000; font-style:italic;">#currently only data_objects is supported</span>
<span style="color:#6666ff; font-weight:bold;">DataMapper::Cutie</span>.<span style="color:#9900CC;">enable_adapter</span> <span style="color:#ff3333; font-weight:bold;">:data_objects</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'dm-cutie-extras'</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Query Plans!</span>
<span style="color:#6666ff; font-weight:bold;">DataMapper::Cutie::Extras</span>.<span style="color:#CC0066; font-weight:bold;">load</span> <span style="color:#ff3333; font-weight:bold;">:mysql_execution_step</span> 
&nbsp;
<span style="color:#008000; font-style:italic;"># Index optimization tips!</span>
<span style="color:#6666ff; font-weight:bold;">DataMapper::Cutie::Extras</span>.<span style="color:#CC0066; font-weight:bold;">load</span> <span style="color:#ff3333; font-weight:bold;">:mysql_index</span> 
&nbsp;
<span style="color:#008000; font-style:italic;"># Mysql Errors and warnings!</span>
<span style="color:#6666ff; font-weight:bold;">DataMapper::Cutie::Extras</span>.<span style="color:#CC0066; font-weight:bold;">load</span> <span style="color:#ff3333; font-weight:bold;">:mysql_warning</span> 
&nbsp;
&nbsp;
<span style="color:#6666ff; font-weight:bold;">DataMapper::Cutie</span>.<span style="color:#9900CC;">setup</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>c<span style="color:#006600; font-weight:bold;">|</span> 
  c<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:repo_name</span><span style="color:#006600; font-weight:bold;">&#93;</span>       = <span style="color:#ff3333; font-weight:bold;">:dm_cutie</span> <span style="color:#008000; font-style:italic;"># name of your repo  </span>
  c<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:exclude_models</span><span style="color:#006600; font-weight:bold;">&#93;</span>  = <span style="color:#0000FF; font-weight:bold;">false</span> <span style="color:#008000; font-style:italic;">#[:person, :car] #models to exclude</span>
  c<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:only_models</span><span style="color:#006600; font-weight:bold;">&#93;</span>     = <span style="color:#0000FF; font-weight:bold;">false</span> <span style="color:#008000; font-style:italic;">#[:article, :address] #model to include</span>
  c<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:slow_query_length</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006666;">2</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;">#Forces Cutie to always migrate HER models</span>
<span style="color:#6666ff; font-weight:bold;">DataMapper::Cutie</span>.<span style="color:#9900CC;">start</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></pre></td></tr></table></div>

<p>Let dm-cutie sit in your code for a while, she will start to generate lost of data on your repository. I would recommend not putting dm-cutie in a production environment due to the amount of queries that it generates. It is best used in a development or a staging environment and then applies the learned optimization strategies to your production environment.</p>
<p>After cutie has been running a while (or immediately if you are impatient) from the command line do:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;">$ dm<span style="color:#006600; font-weight:bold;">-</span>cutie<span style="color:#006600; font-weight:bold;">-</span>ui <span style="color:#006600; font-weight:bold;">-</span><span style="color:#CC0066; font-weight:bold;">p</span> <span style="color:#006666;">4567</span> <span style="color:#006600; font-weight:bold;">--</span>extras=mysql_warning,mysql_index,mysql_execution_step</pre></td></tr></table></div>

<p>If you didn't use any of the extras in your application you SHOULDNT list them when you start the dm-cutie-ui.</p>
<p>That's that.  You just need to sign in using the URI for your repository, it will be something like: mysql://root@localhost/dm_cutie.</p>
<p>An important note is that when you log into dm-cutie-ui you are logging into the dm-cutie repository, not your applications, so keep that in mind so you dont get errors saying the dm-cutie repo doesn't exist.</p>
<p>Well that's it for now, I'll post about this more after the holiday when I make a few more plugins.  Enjoy!</p>
<p>There is a ton more documentation at:</p>
<ul>
<li><a href="http://github.com/coryodaniel/dm-cutie">dm-cutie github page</a></li>
<li><a href="http://github.com/coryodaniel/dm-cutie-ui">dm-cutie-ui github page</a></li>
<li><a href="http://github.com/coryodaniel/dm-cutie-extras">dm-cutie-extras github page</a></li>
</ul>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=DataMapper+Cutie+%E2%80%93+The+query+tracker+and+profiler+http://coryodaniel.com/?p=339" title="Post to Twitter"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://coryodaniel.com/index.php/2009/11/25/datamapper-cutie-the-query-tracker-and-profiler/&amp;title=DataMapper+Cutie+%E2%80%93+The+query+tracker+and+profiler" title="Post to Digg"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-digg-big2.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://coryodaniel.com/index.php/2009/11/25/datamapper-cutie-the-query-tracker-and-profiler/&amp;t=DataMapper+Cutie+%E2%80%93+The+query+tracker+and+profiler" title="Post to Facebook"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-facebook-big2.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://coryodaniel.com/index.php/2009/11/25/datamapper-cutie-the-query-tracker-and-profiler/&amp;title=DataMapper+Cutie+%E2%80%93+The+query+tracker+and+profiler" title="Post to Reddit"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-reddit-big2.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://coryodaniel.com/index.php/2009/11/25/datamapper-cutie-the-query-tracker-and-profiler/&amp;title=DataMapper+Cutie+%E2%80%93+The+query+tracker+and+profiler" title="Post to StumbleUpon"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-su-big2.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://coryodaniel.com/index.php/2009/11/25/datamapper-cutie-the-query-tracker-and-profiler/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>DataMapper Remixable Updates</title>
		<link>http://coryodaniel.com/index.php/2008/12/05/datamapper-remixable-updates/</link>
		<comments>http://coryodaniel.com/index.php/2008/12/05/datamapper-remixable-updates/#comments</comments>
		<pubDate>Sat, 06 Dec 2008 01:52:55 +0000</pubDate>
		<dc:creator>Cory O'Daniel</dc:creator>
				<category><![CDATA[RubyDevelopment]]></category>
		<category><![CDATA[datamapper]]></category>

		<guid isPermaLink="false">http://blog.vokle.com/?p=187</guid>
		<description><![CDATA[DM Remixables 0.9.7 RC 2 is out.  Includes clean accessor name creation, more specs, and the ability to assign methods from the Remixable to generated and remixing classes.  Woot, woot.  See the specs and readme for examples.
    ]]></description>
			<content:encoded><![CDATA[<p><a href="http://rubyforge.org/frs/shownotes.php?release_id=29028" target="_blank">DM Remixables 0.9.7 RC 2 is out.</a>  Includes clean accessor name creation, more specs, and the ability to assign methods from the Remixable to generated and remixing classes.  Woot, woot.  See the specs and readme for examples.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=DataMapper+Remixable+Updates+http://coryodaniel.com/?p=187" title="Post to Twitter"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://coryodaniel.com/index.php/2008/12/05/datamapper-remixable-updates/&amp;title=DataMapper+Remixable+Updates" title="Post to Digg"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-digg-big2.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://coryodaniel.com/index.php/2008/12/05/datamapper-remixable-updates/&amp;t=DataMapper+Remixable+Updates" title="Post to Facebook"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-facebook-big2.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://coryodaniel.com/index.php/2008/12/05/datamapper-remixable-updates/&amp;title=DataMapper+Remixable+Updates" title="Post to Reddit"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-reddit-big2.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://coryodaniel.com/index.php/2008/12/05/datamapper-remixable-updates/&amp;title=DataMapper+Remixable+Updates" title="Post to StumbleUpon"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-su-big2.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://coryodaniel.com/index.php/2008/12/05/datamapper-remixable-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DataMapper is Viewable</title>
		<link>http://coryodaniel.com/index.php/2008/12/05/datamapper-is-viewable/</link>
		<comments>http://coryodaniel.com/index.php/2008/12/05/datamapper-is-viewable/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 20:53:28 +0000</pubDate>
		<dc:creator>Cory O'Daniel</dc:creator>
				<category><![CDATA[RubyDevelopment]]></category>
		<category><![CDATA[datamapper]]></category>
		<category><![CDATA[dm-is-viewable]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.vokle.com/?p=179</guid>
		<description><![CDATA[Even when I'm panicking I'm a fan of datamapper.  I like how clean it generally makes my code, but I do notice that I tend to have the same queries cropping up from time to time either in the same application or in other apps using my model library.  This just wasn't dry enough for [...]]]></description>
			<content:encoded><![CDATA[<p>Even when I'm <a href="http://blog.vokle.com/index.php/2008/10/30/massive-flaw-in-datamapper-096-write-once-read-many-many-many-many-many-im-outta-space-here/" target="_blank">panicking</a> I'm a fan of datamapper.  I like how clean it generally makes my code, but I do notice that I tend to have the same queries cropping up from time to time either in the same application or in other apps using my model library.  This just wasn't dry enough for me, so I made dm-is-viewable.  It gives sql-like view functionality to DataMapper Resources.  It's a pretty simple plugin, but lets take a look, um kay?</p>
<p>Let's start with a really simple User class...</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> User
  <span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#6666ff; font-weight:bold;">DataMapper::Resource</span>
  belongs_to <span style="color:#ff3333; font-weight:bold;">:location</span>
&nbsp;
  property <span style="color:#ff3333; font-weight:bold;">:id</span>, Serial
  property <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#CC0066; font-weight:bold;">String</span>
  property <span style="color:#ff3333; font-weight:bold;">:username</span>, <span style="color:#CC0066; font-weight:bold;">String</span>
  property <span style="color:#ff3333; font-weight:bold;">:password</span>, <span style="color:#CC0066; font-weight:bold;">String</span>
&nbsp;
  property <span style="color:#ff3333; font-weight:bold;">:gender</span>, <span style="color:#CC0066; font-weight:bold;">String</span>
  property <span style="color:#ff3333; font-weight:bold;">:age</span>, <span style="color:#CC0066; font-weight:bold;">Integer</span>
&nbsp;
  property <span style="color:#ff3333; font-weight:bold;">:favorite_color</span>, <span style="color:#CC0066; font-weight:bold;">String</span>
  property <span style="color:#ff3333; font-weight:bold;">:favorite_number</span>, <span style="color:#CC0066; font-weight:bold;">Integer</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Location
  <span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#6666ff; font-weight:bold;">DataMapper::Resource</span>
&nbsp;
  has n, <span style="color:#ff3333; font-weight:bold;">:users</span>
&nbsp;
  property <span style="color:#ff3333; font-weight:bold;">:id</span>, Serial
  property <span style="color:#ff3333; font-weight:bold;">:name</span>, <span style="color:#CC0066; font-weight:bold;">String</span>
  property <span style="color:#ff3333; font-weight:bold;">:desc</span>, <span style="color:#CC0066; font-weight:bold;">String</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Making your resource viewable is pretty easy, first grab the <a href="http://github.com/sam/dm-more/tree/master/dm-is-viewable" target="_blank">dm-is-viewable gem</a>, then say that your resource is viewable.  Views take the exact same parameters that you could pass to Resource.all.  The only difference is that dm-is-viewable stores them until they are called.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> User
  <span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#6666ff; font-weight:bold;">DataMapper::Resource</span>
  is <span style="color:#ff3333; font-weight:bold;">:viewable</span>
&nbsp;
  <span style="color:#008000; font-style:italic;">#lets create some views</span>
  create_view <span style="color:#ff3333; font-weight:bold;">:legal_women</span>, <span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'female'</span>, <span style="color:#ff3333; font-weight:bold;">:age</span>.<span style="color:#9900CC;">gt</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">18</span>
  create_view <span style="color:#ff3333; font-weight:bold;">:serial_killers</span>, <span style="color:#ff3333; font-weight:bold;">:favorite_number</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">666</span>, <span style="color:#ff3333; font-weight:bold;">:favorite_color</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'black'</span>
&nbsp;
  <span style="color:#008000; font-style:italic;">#... Resource code *SNIP SNIP*</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>See the befores and afters below:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Legal Women Before</span>
User.<span style="color:#9900CC;">all</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'female'</span>, <span style="color:#ff3333; font-weight:bold;">:age</span>.<span style="color:#9900CC;">gt</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">18</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Legal Women After</span>
User.<span style="color:#9900CC;">view</span> <span style="color:#ff3333; font-weight:bold;">:legal_women</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Serial killers before</span>
User.<span style="color:#9900CC;">all</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:favorite_number</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">666</span>, <span style="color:#ff3333; font-weight:bold;">:favorite_color</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'black'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Serial killers after</span>
User.<span style="color:#9900CC;">view</span> <span style="color:#ff3333; font-weight:bold;">:serial_killers</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># You can also pass further limiting query parameters to #view.</span>
<span style="color:#008000; font-style:italic;"># Legal Local Women Before</span>
User.<span style="color:#9900CC;">all</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'female'</span>, <span style="color:#ff3333; font-weight:bold;">:age</span>.<span style="color:#9900CC;">gt</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">18</span>, User.<span style="color:#9900CC;">location</span>.<span style="color:#9900CC;">name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'Los Angeles'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Legel Local Women After</span>
User.<span style="color:#9900CC;">view</span> <span style="color:#ff3333; font-weight:bold;">:legal_women</span>, User.<span style="color:#9900CC;">location</span>.<span style="color:#9900CC;">name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'Los Angeles'</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Passing additional parameters FURTHERS the limitation of records, so..</span>
User.<span style="color:#9900CC;">view</span> <span style="color:#ff3333; font-weight:bold;">:legal_women</span>, <span style="color:#ff3333; font-weight:bold;">:gender</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'male'</span>
<span style="color:#008000; font-style:italic;"># =&gt; Would return nil, the query would essentially be generated as:</span>
<span style="color:#008000; font-style:italic;">#  SELECT * from users where gender = 'male' and gender = 'female'</span></pre></td></tr></table></div>

<p>Simply, clean, useful.  Woot.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=DataMapper+is+Viewable+http://coryodaniel.com/?p=179" title="Post to Twitter"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://coryodaniel.com/index.php/2008/12/05/datamapper-is-viewable/&amp;title=DataMapper+is+Viewable" title="Post to Digg"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-digg-big2.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://coryodaniel.com/index.php/2008/12/05/datamapper-is-viewable/&amp;t=DataMapper+is+Viewable" title="Post to Facebook"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-facebook-big2.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://coryodaniel.com/index.php/2008/12/05/datamapper-is-viewable/&amp;title=DataMapper+is+Viewable" title="Post to Reddit"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-reddit-big2.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://coryodaniel.com/index.php/2008/12/05/datamapper-is-viewable/&amp;title=DataMapper+is+Viewable" title="Post to StumbleUpon"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-su-big2.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://coryodaniel.com/index.php/2008/12/05/datamapper-is-viewable/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

