<?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>M. E. Patterson - Author, Geek &#187; mongomapper</title>
	<atom:link href="http://mepatterson.net/tag/mongomapper/feed/" rel="self" type="application/rss+xml" />
	<link>http://mepatterson.net</link>
	<description>bestselling author of Devil&#039;s Hand, a supernatural thriller; writer of fictions and web software</description>
	<lastBuildDate>Sun, 18 Dec 2011 23:19:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
	<!-- google_ad_section_end --><!-- google_ad_section_start -->	<item>
		<title>Nested forms, hashes, checkboxes and MongoMapper</title>
		<link>http://mepatterson.net/2010/02/nested-forms-hashes-checkboxes-and-mongomapper/</link>
		<comments>http://mepatterson.net/2010/02/nested-forms-hashes-checkboxes-and-mongomapper/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 02:39:09 +0000</pubDate>
		<dc:creator>M. E. Patterson</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[inherited_resources]]></category>
		<category><![CDATA[mongod]]></category>
		<category><![CDATA[mongomapper]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[sunspot]]></category>

		<guid isPermaLink="false">http://blog.digimonkey.com/?p=92</guid>
		<description><![CDATA[While working on my upcoming BigAuthor project, I came upon an interesting challenge that turned out to be so simple with MongoMapper that I just have to share it here. Need to create a hash of multiple filter parameters on a MongoMapper document using a form that is cleanly resource-based, using InheritedResources? It&#8217;s not as [...]]]></description>
			<content:encoded><![CDATA[<p>While working on my upcoming BigAuthor project, I came upon an interesting challenge that turned out to be so simple with MongoMapper that I just have to share it here.  Need to create a hash of multiple filter parameters on a MongoMapper document using a form that is cleanly resource-based, using InheritedResources?  It&#8217;s not as difficult as you might think&#8230;<br />
<span id="more-92"></span><br />
In my MongoMapper::Document model, I have the following keys:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">key <span style="color:#ff3333; font-weight:bold;">:title</span>, <span style="color:#CC0066; font-weight:bold;">String</span><br />
key <span style="color:#ff3333; font-weight:bold;">:filters</span>, <span style="color:#CC00FF; font-weight:bold;">Hash</span>, <span style="color:#ff3333; font-weight:bold;">:index</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span></div></div>
<p>Now, I&#8217;m expecting to stick a Hash into &#8216;filters&#8217; in the form:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#996600;">'colors'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'red'</span>,<span style="color:#996600;">'green'</span>,<span style="color:#996600;">'blue'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <br />
&nbsp; <span style="color:#996600;">'people'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'joe'</span>,<span style="color:#996600;">'mary'</span><span style="color:#006600; font-weight:bold;">&#93;</span>, <br />
&nbsp; <span style="color:#996600;">'tags'</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'dog cat vampire zombie'</span><span style="color:#006600; font-weight:bold;">&#125;</span></div></div>
<p>So, the idea is, the object that is saved with the above filters Hash provides a context for searching through another collection of objects (let&#8217;s call it OtherThings) using the filters.  (think email rules in Outlook).  Anyway, don&#8217;t worry too much about that.  It&#8217;ll become more clear once I launch BigAuthor in a few weeks or so.</p>
<p>Using <a href="http://github.com/josevalim/inherited_resources">InheritedResources</a> + <a href="http://github.com/justinfrench/formtastic">Formtastic</a> gives you a big advantage in creating resourceful controllers and their associated semantic forms really, really quickly.</p>
<p>The controller:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">class</span> ThingsController <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">InheritedResources::Base</span><br />
&nbsp; respond_to <span style="color:#ff3333; font-weight:bold;">:html</span>, <span style="color:#ff3333; font-weight:bold;">:xml</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>Seriously.  It&#8217;s that empty.</p>
<p>The &#8216;new&#8217; form page (in HAML, of course):</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#006600; font-weight:bold;">%</span>h1 Add a New Thing<br />
<span style="color:#006600; font-weight:bold;">-</span> semantic_form_for <span style="color:#0066ff; font-weight:bold;">@things</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>form<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; <span style="color:#006600; font-weight:bold;">-</span> form.<span style="color:#9900CC;">inputs</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; = form.<span style="color:#9900CC;">input</span> <span style="color:#ff3333; font-weight:bold;">:title</span><br />
&nbsp; <span style="color:#006600; font-weight:bold;">-</span> form.<span style="color:#9900CC;">semantic_fields_for</span> <span style="color:#ff3333; font-weight:bold;">:filters</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span><span style="color:#CC0066; font-weight:bold;">sub</span><span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">-</span> <span style="color:#CC0066; font-weight:bold;">sub</span>.<span style="color:#9900CC;">inputs</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; &nbsp; = <span style="color:#CC0066; font-weight:bold;">sub</span>.<span style="color:#9900CC;">input</span> <span style="color:#ff3333; font-weight:bold;">:tags</span><br />
&nbsp; &nbsp; &nbsp; = <span style="color:#CC0066; font-weight:bold;">sub</span>.<span style="color:#9900CC;">input</span> <span style="color:#ff3333; font-weight:bold;">:colors</span>, <span style="color:#ff3333; font-weight:bold;">:collection</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#6666ff; font-weight:bold;">Thing::COLORS</span>, <span style="color:#ff3333; font-weight:bold;">:as</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:check_boxes</span><br />
&nbsp; &nbsp; &nbsp; = <span style="color:#CC0066; font-weight:bold;">sub</span>.<span style="color:#9900CC;">input</span> <span style="color:#ff3333; font-weight:bold;">:people</span>, <span style="color:#ff3333; font-weight:bold;">:collection</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> People.<span style="color:#9900CC;">for_filters</span>, <span style="color:#ff3333; font-weight:bold;">:as</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:check_boxes</span> &nbsp; &nbsp; &nbsp; <br />
&nbsp; <span style="color:#006600; font-weight:bold;">-</span> form.<span style="color:#9900CC;">buttons</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; = form.<span style="color:#9900CC;">commit_button</span> <span style="color:#ff3333; font-weight:bold;">:label</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;Create Thing&quot;</span></div></div>
<p>Again, that&#8217;s it.  Really.  The checkboxes that are checked get put into Arrays within a params['thing']['filters'] Hash and persist naturally to MongoDB through MongoMapper.  No extra work needed.</p>
<p>In fact, the only extra thing I did was to write a short override into the create/update methods so that it strips the blanks from the internal filter arrays.  (formtastic&#8217;s checkboxes post an empty string for every checkbox that is not checked, which in this case wasn&#8217;t what I wanted, but it might be fine or even required for your purposes)</p>
<p>BONUS!</p>
<p>Using <a href="http://outoftime.github.com/sunspot/">Sunspot</a> and Solr for your search solution in your MongoMapper app?  Here&#8217;s a sample of the search method that my OtherThing class has for creating a search result set based on the filters:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">search_with_filters</span><span style="color:#006600; font-weight:bold;">&#40;</span>filters<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; Sunspot.<span style="color:#9900CC;">search</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span><br />
&nbsp; &nbsp; keywords filters<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'tags'</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; with<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:color</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">any_of</span> filters<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'colors'</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; with<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:people</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">any_of</span> filters<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'people'</span><span style="color:#006600; font-weight:bold;">&#93;</span><br />
&nbsp; &nbsp; order_by <span style="color:#ff3333; font-weight:bold;">:created_at</span>, <span style="color:#ff3333; font-weight:bold;">:desc</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>Exactly how my Sunspot/Solr is setup, I&#8217;ll leave for the reader to imagine, but don&#8217;t overthink it&#8230; it&#8217;s not complicated and the above works fast&#8230; really, really fast.  So fast, that instead of pre-creating and caching the results sets, I just re-generate them on the fly, thereby ensuring they&#8217;re always up-to-the-second with the latest OtherThings that have been added to the database.</p>
<p>Once again, Mongo and MongoMapper blows me away with its simplicity, further supported by the brilliant <a href="http://github.com/josevalim/inherited_resources">inherited_resources</a> and <a href="http://github.com/justinfrench/formtastic">formtastic</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://mepatterson.net/2010/02/nested-forms-hashes-checkboxes-and-mongomapper/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Starting a new Rails app?  Here&#8217;s my skeleton&#8230;</title>
		<link>http://mepatterson.net/2010/02/starting-a-new-rails-app-heres-my-skeleton/</link>
		<comments>http://mepatterson.net/2010/02/starting-a-new-rails-app-heres-my-skeleton/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 20:02:19 +0000</pubDate>
		<dc:creator>M. E. Patterson</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[mongomapper]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.digimonkey.com/?p=81</guid>
		<description><![CDATA[Not meant to be a &#8220;this is what should be done&#8221; as much as a &#8220;this is what Matt uses, based largely on community popularity, best practice, and Matt&#8217;s personal tastes.&#8221; Take it for what it is: a point of discussion. Of course, the skeleton of any Rails app will vary from project to project, [...]]]></description>
			<content:encoded><![CDATA[<p>Not meant to be a &#8220;this is what should be done&#8221; as much as a &#8220;this is what Matt uses, based largely on community popularity, best practice, and Matt&#8217;s personal tastes.&#8221;</p>
<p>Take it for what it is: a point of discussion.</p>
<p>Of course, the skeleton of any Rails app will vary from project to project, depending on needs.  Agile approach is to only add it to your framework if you actually need it <em>right now</em>, though some stuff tends to be easier to use (like authentication systems and databases) if you build it in up-front.  That tends to be my approach for green-fielding Rails apps.</p>
<p>If you&#8217;ve got some favorites that <em>you</em> use, feel free to post in the comments about it!  I&#8217;m always interested in hearing about new stuff that makes my life easier/more fun.<br />
<span id="more-81"></span></p>
<h3>FOR MY ACTIVERECORD-BASED APPS</h3>
<ul>
<li> <strong>inherited_resources</strong>
<ul>
<li> for building clean, simple resource-oriented controllers.  the Rails 3.0 guys <a id="j8wo" title="recommend you start using this" href="http://www.enlightsolutions.com/articles/five-ways-to-prepare-your-application-for-ruby-on-rails-3-today/">recommend you start using this</a> with Rails 2.3.5 apps because Rails 3.0&#8242;s new controller syntax is basically derived from inherited_resources (and jose valim is on the rails core team now)</li>
</ul>
</li>
<li> <strong>authlogic</strong>
<ul>
<li> the reigning champ (in my opinion) for a while in terms of a really simple, basic user authentication solution.  i&#8217;ve also tried clearance, lockdown, ye olde restful_authentication, and others.  I still like authlogic alot, but the new Devise system seems to be really solid and might be good enough to get me to switch for new apps</li>
</ul>
</li>
<li> <strong>searchlogic</strong>
<ul>
<li> really handy extra methods for activerecord queries</li>
</ul>
</li>
<li> <strong>haml / sass</strong>
<ul>
<li> blah blah blah <a href="http://blog.digimonkey.com/2010/02/why-use-haml-and-sass-i-already-know-html/">http://blog.digimonkey.com/2010/02/why-use-haml-and-sass-i-already-know-html/ </a></li>
</ul>
</li>
<li> <strong>formtastic</strong> &#8212; <a href="http://github.com/justinfrench/formtastic">http://github.com/justinfrench/formtastic</a>
<ul>
<li> if you intend to produce semantically-correct, standards-compliant xhtml, your biggest enemy is trying to get forms to both look right and be semantic xhtml.  formtastic takes you a long way towards that goal, while also cleaning up your views significantly. and if you need to do something weird for a form that doesn&#8217;t quite work with formtastic, it doesn&#8217;t get in your way.</li>
</ul>
</li>
<li> <strong>compass + blueprint</strong>
<ul>
<li> blueprint is just a CSS framework for laying out 950px wide fixed layouts in a clean way; particularly great for multi-column layouts, which can be notoriously tricky to get right and cross-browser</li>
<li> compass adds a layer on top of blueprint + Sass to make html/css design really easy and slick; saves you a TON of time and makes it easier to get the cross-browser stuff working (or 99% working) on the first try, instead of spending a whole day fighting IE 7</li>
</ul>
</li>
<li> <strong>hoptoad</strong>
<ul>
<li> exception notification to a third-party service that integrates with lighthouse, github, et al</li>
</ul>
</li>
<li> <strong>acts_as_state_machine</strong>
<ul>
<li> self-explanatory</li>
</ul>
</li>
<li> <strong>acts_as_taggable_on_steroids</strong></li>
<li> <strong>acts_as_rateable_with_weights</strong> (mine) &#8211; <a id="u20v" title="http://github.com/mepatterson/acts_as_rateable_with_weights" href="http://github.com/mepatterson/acts_as_rateable_with_weights">http://github.com/mepatterson/acts_as_rateable_with_weights</a>
<ul>
<li> forked my own version of acts_as_rateable to add weighted ratings and bayesian averages</li>
</ul>
</li>
<li> <strong>will_paginate</strong>
<ul>
<li> makes it much easier to handle pagination on <em>any </em>enumerable object collection (ActiveRecord objects or not)</li>
</ul>
</li>
<li> <strong>ssl_requirement</strong>
<ul>
<li> allows you to lock down controller methods so they won&#8217;t work unless the requestor is hitting them through SSL</li>
</ul>
</li>
<li> <strong>statistics</strong> &#8211; <a id="zf5s" title="http://github.com/acatighera/statistics" href="http://github.com/acatighera/statistics">http://github.com/acatighera/statistics</a>
<ul>
<li> have used this exactly once.  liked it, but didn&#8217;t use a ton of its features.  seems pretty robust though.</li>
</ul>
</li>
<li> <strong>jrails</strong> plugin (+ nuke the prototype stuff and replace with jquery)
<ul>
<li> self-explanatory; prototype is dead. long live jquery.</li>
</ul>
</li>
<li> <strong>xapian</strong> or <strong>thinking_sphinx</strong>
<ul>
<li> i&#8217;ve gone through so many different search engines for so many projects.  I think I&#8217;m the only one using Xapian.  It actually works pretty well, but is lacking in a lot of ways.  Thinking sphinx is similar; easier Rails integration, but missing some stuff, though it&#8217;s highlighting and excerpting work nicely.</li>
</ul>
</li>
<li> <strong>paperclip</strong>
<ul>
<li> super-simple file attachments on ActiveRecord models</li>
</ul>
</li>
<li> <strong>carmen</strong> &#8212; <a id="nu18" title="http://github.com/jim/carmen" href="http://github.com/jim/carmen">http://github.com/jim/carmen</a>
<ul>
<li> &#8220;helpful collection of geographic names and abbreviations for Rails apps (includes replacements for country_select and state_select)&#8221;</li>
</ul>
</li>
<li> <strong>stringex</strong> &#8212; <a id="fv2l" title="http://github.com/rsl/stringex" href="http://github.com/rsl/stringex">http://github.com/rsl/stringex</a>
<ul>
<li> helpful assortment of extra string methods</li>
</ul>
</li>
<li> <strong>admin-data</strong> &#8212; <a id="qqkd" title="http://github.com/neerajdotname/admin_data" href="http://github.com/neerajdotname/admin_data">http://github.com/neerajdotname/admin_data</a>
<ul>
<li> every app ends up needing some sort of admin backend to rifle through the data layer, at the very least in development mode; pretty useful</li>
</ul>
</li>
<li> <strong>bullet</strong> &#8212; <a id="agmh" title="http://github.com/flyerhzm/bullet" href="http://github.com/flyerhzm/bullet">http://github.com/flyerhzm/bullet</a>
<ul>
<li> stupid-simple plugin that helps you find N+1 queries and other query performance problems</li>
</ul>
</li>
<li> <strong>factory_girl</strong>, <strong>shoulda</strong>, <strong>faker</strong>
<ul>
<li> i liked factory_girl a lot until my company started using machinist, so now I think I like that better.  shoulda is great.  faker is indispensable, imho.</li>
</ul>
</li>
<li> <strong>db-populate </strong>&#8211; <a id="bxz9" title="http://github.com/ffmike/db-populate" href="http://github.com/ffmike/db-populate">http://github.com/ffmike/db-populate</a>
<ul>
<li> i&#8217;ve been using this in my older AR-backed apps.  probably won&#8217;t need it in 2.3.5 or 3.0 apps, though i do like how ffmike did db-populate.  i think it might still be more robust than the db:seed thing built-in to Rails</li>
</ul>
</li>
</ul>
<h3>FOR MY MONGO_MAPPER APPS</h3>
<ul>
<li> <strong>mongo</strong>
<ul>
<li> [GEM] the base MongoDB ruby driver</li>
</ul>
</li>
<li> <strong>mongo_ext</strong>
<ul>
<li> [GEM] C-extensions for the above to make it perform better</li>
</ul>
</li>
<li> <strong>mongo_mapper</strong>
<ul>
<li> [GEM] John Nunemaker&#8217;s thin ORM layer for Mongo.  fairly young and poorly documented, but it&#8217;s such a thin wrapper that it hasn&#8217;t been a problem for me.  just gives you some basic ActiveRecord-ish relationships and conveniences for using Mongo Documents and EmbeddedDocuments with standard Ruby models.</li>
<li> <a href="http://railstips.org/blog/archives/2009/06/27/mongomapper-the-rad-mongo-wrapper/">http://railstips.org/blog/archives/2009/06/27/mongomapper-the-rad-mongo-wrapper/</a></li>
<li> <a href="http://railstips.org/blog/archives/2009/12/18/why-i-think-mongo-is-to-databases-what-rails-was-to-frameworks/">http://railstips.org/blog/archives/2009/12/18/why-i-think-mongo-is-to-databases-what-rails-was-to-frameworks/</a></li>
<li> <a id="tlav" title="http://rdoc.info/projects/jnunemaker/mongomapper" href="http://rdoc.info/projects/jnunemaker/mongomapper">http://rdoc.info/projects/jnunemaker/mongomapper</a></li>
</ul>
</li>
<li> <strong>sunspot</strong>[GEM] + <strong>sunspot_rails</strong>[GEM] (with custom config for mongo support) &#8211; <a id="yy.0" title="http://github.com/outoftime/sunspot" href="http://github.com/outoftime/sunspot">http://github.com/outoftime/sunspot</a>
<ul>
<li> found that sunspot integrates the solr search engine more easily with mongo than anything else out there.  has a lot of nice features, and it does automatic indexing on the fly, rather than requiring some sort of nasty cron job or handrolled delta-indexing solution</li>
</ul>
</li>
<li> <em>handrolled auth system derived in part from</em> <strong>authlogic</strong>
<ul>
<li> so, i probably should start using Devise, since it apparently has native mongo_mapper support.  but for the two mongo apps I&#8217;ve built thus far, i just handrolled a simple authentication system by adapting the core code from authlogic and removing all the ActiveRecord-specific bits.  works fine, easy to add on custom stuff.  but Devise is probably better for the future.</li>
</ul>
</li>
<li> <strong>machinist</strong>, <strong>shoulda</strong>, <strong>faker</strong>
<ul>
<li> see above</li>
</ul>
</li>
<li> <strong>acts_as_mongo_rateable</strong> (mine) &#8212; <a id="c2pf" title="http://github.com/mepatterson/acts_as_mongo_rateable" href="http://github.com/mepatterson/acts_as_mongo_rateable">http://github.com/mepatterson/acts_as_mongo_rateable</a>
<ul>
<li> I wrote this from scratch, inspired by the basic architecture of the acts_as_rateable plugin for ActiveRecord</li>
</ul>
</li>
<li> <strong>acts_as_mongo_taggable</strong> (mine) &#8211; <a id="hu4g" title="http://github.com/mepatterson/acts_as_mongo_taggable" href="http://github.com/mepatterson/acts_as_mongo_taggable">http://github.com/mepatterson/acts_as_mongo_taggable</a>
<ul>
<li> I wrote this from scratch, inspired by the basic architecture of the acts_as_taggable_on_steroids plugin for ActiveRecord</li>
</ul>
</li>
<li> <strong>will_paginate</strong>
<ul>
<li> works fine with any enumerable object, so works with Mongo</li>
</ul>
</li>
<li> <strong>compass</strong> + <strong>blueprint</strong>
<ul>
<li> see above</li>
</ul>
</li>
<li> <strong>haml</strong> / <strong>sass</strong>
<ul>
<li> see above</li>
</ul>
</li>
<li> <strong>jrails</strong> plugin (+ jquery instead of prototype)
<ul>
<li> see above</li>
</ul>
</li>
<li> <strong>inherited_resources</strong>
<ul>
<li> this works largely the same with Mongo, since your resource-based controller shouldn&#8217;t really have any direct dependence on your database ORM</li>
</ul>
</li>
<li> <strong>hoptoad</strong>
<ul>
<li> see above</li>
</ul>
</li>
</ul>
<h3>STUFF I&#8217;D LIKE TO USE/WANT TO INVESTIGATE FURTHER</h3>
<ul>
<li> <strong>devise</strong> &#8211; <a id="bkx-" title="http://github.com/plataformatec/devise" href="http://github.com/plataformatec/devise">http://github.com/plataformatec/devise</a>
<ul>
<li> has mongo support baked in!  looks really cool and has a lot of robust functionality.</li>
<li> example using with mongomapper &#8211; <a id="hpu." title="http://github.com/theshortcut/devise_mongomapper_example" href="http://github.com/theshortcut/devise_mongomapper_example">http://github.com/theshortcut/devise_mongomapper_example</a></li>
</ul>
</li>
<li> <strong>easy ESI</strong> &#8212; <a id="c_ix" title="http://github.com/grosser/easy_esi" href="http://github.com/grosser/easy_esi">http://github.com/grosser/easy_esi</a>
<ul>
<li> haven&#8217;t looked at it much; seems like an interesting approach</li>
</ul>
</li>
<li> <strong>aegis</strong> &#8211; <a id="g-bj" title="http://github.com/makandra/aegis" href="http://github.com/makandra/aegis">http://github.com/makandra/aegis</a>
<ul>
<li> seems like a really nice way to do complicated roles and permissions.  haven&#8217;t used it though.  dunno if it will work with any of the good auth systems like devise, clearance, authlogic, etc.  in most cases, might just be easier to write your own simple roles system (which is what i&#8217;ve done in ALL cases)</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://mepatterson.net/2010/02/starting-a-new-rails-app-heres-my-skeleton/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Mongo Beauty #1</title>
		<link>http://mepatterson.net/2010/02/mongo-beauty-1/</link>
		<comments>http://mepatterson.net/2010/02/mongo-beauty-1/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 05:29:23 +0000</pubDate>
		<dc:creator>M. E. Patterson</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[mongomapper]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.digimonkey.com/?p=64</guid>
		<description><![CDATA[Frequently, while working with MongoDB and MongoMapper, I run across an implementation of something that blows me away with its beauty. This, my friends, is one of those times. Given: a Users collection where the users&#8217; names are stored in an Array key called name. i.e. :name => ["Patterson", "Matt"]. It can be any length, [...]]]></description>
			<content:encoded><![CDATA[<p>Frequently, while working with MongoDB and MongoMapper, I run across an implementation of something that blows me away with its beauty.  This, my friends, is one of those times.  </p>
<p>Given: a Users collection where the users&#8217; names are stored in an Array key called name.  i.e. :name => ["Patterson", "Matt"].  It can be any length, so if they want middle names or titles or whatever, it just gets stuck in there as an element on the array.</p>
<p>Problem: Need to create a really quick lookup to do autocomplete when someone is looking for a particular person in the database.</p>
<p>Solution:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">named</span><span style="color:#006600; font-weight:bold;">&#40;</span>query<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; User.<span style="color:#9900CC;">all</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>^<span style="color:#008000; font-style:italic;">#{query}.*/i })</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>So when the user types &#8220;m&#8221; into the autocomplete field, it will quickly populate the suggestions with ["Patterson", "Matt"] and ["Magdalene", "Mary"] and ["Munchausen", "Baron"] and ["Mr.", "John", "Arbuckle"].  But it won&#8217;t pickup people with &#8216;m&#8217; in the middle of any of their name components, like ["Hammer", "Captain"].</p>
<p>How simple is that?</p>
<p>UPDATE: 11 Apr 2010<br />
As it turns out, you can make the above even <em>faster</em>:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">named</span><span style="color:#006600; font-weight:bold;">&#40;</span>query<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; &nbsp; User.<span style="color:#9900CC;">all</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">/</span>^<span style="color:#008000; font-style:italic;">#{query}/i })</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div></div>
<p>without the &#8216;.*&#8217; bit, apparently mongo&#8217;s regex implementation gets a huge speed boost since it&#8217;s not having to parse the rest of the string once it hits a match.</p>
]]></content:encoded>
			<wfw:commentRss>http://mepatterson.net/2010/02/mongo-beauty-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	<!-- google_ad_section_end --></channel>
</rss>

