<?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>ben koonse &#187; rails</title>
	<atom:link href="http://bennyfreshness.com/category/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://bennyfreshness.com</link>
	<description>wrestling code into submission...</description>
	<lastBuildDate>Tue, 11 Oct 2011 19:38:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>Rails 3: Organic Unicorn Whispers</title>
		<link>http://bennyfreshness.com/2010/07/rails-3-organic-unicorn-whispers/</link>
		<comments>http://bennyfreshness.com/2010/07/rails-3-organic-unicorn-whispers/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 07:15:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://bennyfreshness.com/?p=184</guid>
		<description><![CDATA[Ladies and gentleman, I&#8217;m about to jack you up with some tasty treats. Thats right, prepare to get hit in the face with a fist of refreshing merriment. You think this is a joke? Cause I&#8217;m not laughing&#8230; Rails 3.. This bundle of delight is sure to put a smile on your ugly ass. So [...]]]></description>
			<content:encoded><![CDATA[<p>Ladies and gentleman, I&#8217;m about to jack you up with some tasty treats. Thats right, prepare to get hit in the face with a fist of refreshing merriment. You think this is a joke? Cause I&#8217;m not laughing&#8230;</p>
<p>Rails 3.. This bundle of delight is sure to put a smile on your ugly ass. So scrumptious in fact, after reading this blog post you&#8217;re probably going to do one of two things.</p>
<p>• frolic through the sunkissed meadow blowing dandelion petals<br />
• feed splashing narwhals sardines out of you smiling mouth</p>
<p>Thats the kind of elation you&#8217;ll get when you bear witness to what Rails 3 pony&#8217;s up. Pretty much on par with organic unicorn whispers.</p>
<p><span id="more-184"></span></p>
<p>Lets begin this exaltation with our rapture from dependency hell. Meet my new best friend <a href="http://gembundler.com/" target="_blank">bundler</a>. 1.) Specify your gems in a Gemfile  2.) Run &#8220;bundle install&#8221; 3.) Profit.. Need to lock down your gems? &#8220;bundle lock&#8221; I&#8217;ll let you marinate on that for a second&#8230;</p>
<p>Scope this player..</p>
<pre>  class Post &lt; ActiveRecord::Base
    scope :published, lambda {
      where("posts.published_at &lt;= ?", Time.zone.now)
    }
    scope :published_since, lambda { |ago|
      published.where("posts.published_at &gt;= ?", ago)
    }
    scope :recent, published.order("posts.published_at DESC")
  end</pre>
<p>Stop drooling all over your keyboard for a second there chief and reflect on the allure of these refactored <a href="http://edgerails.info/articles/what-s-new-in-edge-rails/2010/02/23/the-skinny-on-scopes-formerly-named-scope/" target="_blank">scoping</a> methods. Ahhh, yes..</p>
<p>Moving on, stay with me..</p>
<p>No more pouting over routing. Rails 3 sprinked nectar all over <a href="http://yehudakatz.com/2009/12/26/the-rails-3-router-rack-it-up/" target="_blank">routing&#8217;s</a> face. Basically, more minimalist, succinct, powerful, flexible, sexy routing. e.g.</p>
<pre>  # Rails 3
  root :to =&gt; 'forthe#win'

  # Rails 2
  map.root :controller =&gt; "forthe", :action =&gt; 'win'

  # Rails 3
  resources :products do
    resource :category
    member do
      post :short
    end
    collection do
      get :long
    end
  end

  # Rails 2
  map.resources :products, :member =&gt; {:short =&gt; :post}, :collection =&gt; {:long =&gt; :get} do |products|
    products.resource :category
  end</pre>
<p>Still want more, fine.. How about agnosticism? Use whatever ORM you like. Use whatever javascript library your pretty little head desires. Rails 3 won&#8217;t judge you.</p>
<p>Well cupcake, so ends another spectacularly humorless blog post..  Hopefully you&#8217;re not nauseated by my writing and are becoming elated to <a href="http://weblog.rubyonrails.org/2010/2/5/rails-3-0-beta-release" target="_blank">begin</a> working with Rails 3.</p>
]]></content:encoded>
			<wfw:commentRss>http://bennyfreshness.com/2010/07/rails-3-organic-unicorn-whispers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sunspot Showed Me the Light</title>
		<link>http://bennyfreshness.com/2010/05/sunspot-showed-me-the-light/</link>
		<comments>http://bennyfreshness.com/2010/05/sunspot-showed-me-the-light/#comments</comments>
		<pubDate>Thu, 20 May 2010 07:06:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[sunspot]]></category>

		<guid isPermaLink="false">http://bennyfreshness.com/?p=151</guid>
		<description><![CDATA[Ladies and gentleman, gone are the dark ages of using SQL (a known gateway drug) to perform searches. Thats right, I&#8217;m here today to spotlight Sunspot, &#8220;a Ruby library for expressive, powerful interaction with the Solr search engine.&#8221; Ever since that fated column of light struck my monitor and forced my browser to google Solr, [...]]]></description>
			<content:encoded><![CDATA[<p>Ladies and gentleman, gone are the dark ages of using SQL (a known gateway drug) to perform searches.  Thats right, I&#8217;m here today to spotlight <a href="http://outoftime.github.com/sunspot/" target="_blank">Sunspot</a>, &#8220;a Ruby library for expressive, powerful interaction with the Solr search engine.&#8221;</p>
<p>Ever since that fated column of light struck my monitor and forced my browser to google <a href="http://lucene.apache.org/solr/" target="_blank">Solr</a>, I&#8217;ve had the strength to overcome my addiction to SQL searches.  Gone are the days of &#8220;select intervention_date from developers where search_method like &#8216;%sql%&#8217;&#8221;</p>
<p>Get out of that darkness cupcake! Let some light brighten up that dark and dreary world of murky sql search statements and enter a radiant and luminous world of vibrant Sunspot search!</p>
<p><span id="more-151"></span></p>
<p>We can get through this together&#8230;</p>
<p>Step 1: Installation</p>
<pre>
  gem install sunspot
  gem install sunspot_rails
</pre>
<p>Step 2: Define What to Index</p>
<pre>
  class Rehab
    #...
  end

  Sunspot.setup(Rehab) do
    text :addiction
    integer :relapses
    float :relapse_average
    time :admitted_at
    string :cure do
      addiction.gsub(/(darkness|clouds|shadows)/, 'sunshine')
    end
  end
</pre>
<p>Step 3: Search</p>
<pre>
  search = Sunspot.search Rehab do
    keywords 'light sunshine'
    with :patient_name, 'Benny Freshness'
    with(:relapses).any_of [2, 14]
    with(:relapse_average).less_than 4
    any_of do
      with(:admitted_at).less_than(Time.now)
    end
    without :cure, 'Moar SQL'
    order_by :average_relapse, :desc
    facet :cure
  end</pre>
<p>Step 4: Profit</p>
<p>In all cerealness, I&#8217;d like to shed light on the line &#8216;facet :cure&#8217; for a lightsecond as this really illuminates the vibrance of Sunspot.  A &#8220;<a href="http://wiki.apache.org/solr/SimpleFacetParameters" target="_blank">facet</a>&#8221; is a glint of search aurora.  Say my search lights up 45 results, by faceting on cure, we can get tallies of how many of each distinct cures are retuned in the result set e.g &#8216;moar SQL&#8217;:10, &#8216;Solr&#8217;:5, &#8216;Sunspot&#8217;:25, &#8216;Zippo&#8217;:1</p>
<p>By faceting we can irradiate our result set and re-kindle that old flame for search burning inside us all.</p>
<p>Furthermore, feast on these tasty Sunspot nuggets:</p>
<blockquote>
<ol>
<li>kindergarden easy index control</li>
<li>keyword search, ordering, scoping, awesomeing</li>
<li>indexing custom/dynamic field goodness</li>
<li>DSL which feels like your native toungue</li>
<li>faceting for days, CUSTOM FACETS!!</li>
<li>extensible, pick an ORM, any ORM</li>
<li>will_play with will_paginate</li>
<li>order by field value, relevance, geographical distance, or your face</li>
</ol>
</blockquote>
<p>Well folks, thats all I can illuminate for you here today.  Hopefully my annoying &#8220;light&#8221; analogies don&#8217;t have you plotting to kill me by now. I also hope I cast some light on something you might be able to use or find interesting.</p>
<p>So remember, use the force, don&#8217;t join the dark side of SQL searching, step into the magnificent light of Sunspot!</p>
]]></content:encoded>
			<wfw:commentRss>http://bennyfreshness.com/2010/05/sunspot-showed-me-the-light/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

