<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"><channel><description></description><title>Sam Schenkman-Moore's code snips</title><generator>Tumblr (3.0; @samsmcode)</generator><link>http://code.samsm.com/</link><item><title>The Rails Way: RailsConf Recap: Skinny Controllers</title><description>&lt;a href="http://www.therailsway.com/2007/6/1/railsconf-recap-skinny-controllers"&gt;The Rails Way: RailsConf Recap: Skinny Controllers&lt;/a&gt;</description><link>http://code.samsm.com/post/2893954</link><guid>http://code.samsm.com/post/2893954</guid><pubDate>Sun, 03 Jun 2007 22:10:48 -0400</pubDate></item><item><title>Hackety Hack: the Coder's Starter Kit</title><description>&lt;a href="http://hacketyhack.net/"&gt;Hackety Hack: the Coder's Starter Kit&lt;/a&gt;</description><link>http://code.samsm.com/post/1261271</link><guid>http://code.samsm.com/post/1261271</guid><pubDate>Thu, 26 Apr 2007 15:39:22 -0400</pubDate></item><item><title>the { buckblogs :here }: begin + else</title><description>&lt;a href="http://weblog.jamisbuck.org/2007/2/8/begin-else"&gt;the { buckblogs :here }: begin + else&lt;/a&gt;</description><link>http://code.samsm.com/post/1261273</link><guid>http://code.samsm.com/post/1261273</guid><pubDate>Thu, 26 Apr 2007 15:39:22 -0400</pubDate></item><item><title>Get ActiveRecord to Only Select a Couple Rows</title><description>&lt;a href="http://www.didcoe.id.au/archives/why-get-more-than-you-need"&gt;Get ActiveRecord to Only Select a Couple Rows&lt;/a&gt;</description><link>http://code.samsm.com/post/1261274</link><guid>http://code.samsm.com/post/1261274</guid><pubDate>Thu, 26 Apr 2007 15:39:22 -0400</pubDate></item><item><title>Scott's Place : New Rails feature: simply_helpful</title><description>&lt;a href="http://matthewman.net/articles/2006/09/04/new-rails-feature-simply_helpful"&gt;Scott's Place : New Rails feature: simply_helpful&lt;/a&gt;</description><link>http://code.samsm.com/post/1261275</link><guid>http://code.samsm.com/post/1261275</guid><pubDate>Thu, 26 Apr 2007 15:39:22 -0400</pubDate></item><item><title>the { buckblogs :here }: begin + else</title><description>&lt;a href="http://weblog.jamisbuck.org/2007/2/8/begin-else"&gt;the { buckblogs :here }: begin + else&lt;/a&gt;</description><link>http://code.samsm.com/post/137374</link><guid>http://code.samsm.com/post/137374</guid><pubDate>Mon, 12 Mar 2007 20:45:03 -0400</pubDate></item><item><title>Get ActiveRecord to Only Select a Couple Rows</title><description>&lt;a href="http://www.didcoe.id.au/archives/why-get-more-than-you-need"&gt;Get ActiveRecord to Only Select a Couple Rows&lt;/a&gt;</description><link>http://code.samsm.com/post/114405</link><guid>http://code.samsm.com/post/114405</guid><pubDate>Sat, 10 Mar 2007 15:33:57 -0500</pubDate></item><item><title>Basic Ruby Module behavior, class methods and instance methods for the implementing class.</title><description>&lt;p&gt;&lt;textarea name="code" class="ruby" cols="60" rows="20"&gt;module SampleModule&lt;br/&gt;
  module ClassMethods&lt;br/&gt;
    def class_method_one&lt;br/&gt;
      puts ‘hi, class method here’&lt;br/&gt;
    end&lt;br/&gt;
  end&lt;br/&gt;&lt;br/&gt;
  def self.included(base)&lt;br/&gt;
    base.extend(ClassMethods)&lt;br/&gt;
  end&lt;br/&gt;&lt;br/&gt;
  def instance_method_one&lt;br/&gt;
    puts ‘howdy do, instance method here’&lt;br/&gt;
  end&lt;br/&gt;
end&lt;/textarea&gt;&lt;/p&gt;

&lt;p&gt;class ImplementingModule&lt;br/&gt;
  include SampleModule&lt;br/&gt;
end&lt;/p&gt;

&lt;p&gt;ImplementingModule.class_method_one # hi, class method here&lt;br/&gt;
ImplementingModule.new.instance_method_one # howdy do, instance method here&lt;br/&gt;&lt;/p&gt;</description><link>http://code.samsm.com/post/53348</link><guid>http://code.samsm.com/post/53348</guid><pubDate>Mon, 05 Mar 2007 12:21:56 -0500</pubDate></item><item><title>Scott's Place : New Rails feature: simply_helpful</title><description>&lt;a href="http://matthewman.net/articles/2006/09/04/new-rails-feature-simply_helpful"&gt;Scott's Place : New Rails feature: simply_helpful&lt;/a&gt;</description><link>http://code.samsm.com/post/46435</link><guid>http://code.samsm.com/post/46435</guid><pubDate>Sun, 04 Mar 2007 22:40:23 -0500</pubDate></item><item><title>An array of id values in order into an array of ActiveRecord objects in order (one query)</title><description>&lt;textarea name="code" class="ruby" cols="60" rows="20"&gt;ordered_ids = [4, 5, 7, 4, 12, 2]&lt;br/&gt;
people = Person.find(array) # people is unordered, no duplicates&lt;br/&gt;
people_in_order_including_duplicates = ordered_ids.collect { |x|&lt;br/&gt;
  people.detect {|p| &lt;br/&gt;
    p.id == x &lt;br/&gt;
  }&lt;br/&gt;
}&lt;br/&gt;&lt;/textarea&gt;&lt;br/&gt;
I originally did this using enumerable’s “find”, but “detect” is the exact same method and doesn’t carry the same ActiveRecord baggage.</description><link>http://code.samsm.com/post/46208</link><guid>http://code.samsm.com/post/46208</guid><pubDate>Sun, 04 Mar 2007 22:18:56 -0500</pubDate></item><item><title>This is my best tip.</title><description>&lt;p&gt;&lt;textarea name="code" class="ruby" cols="60" rows="20"&gt;unfamiliar_object.methods # … 100+ results&lt;/textarea&gt;&lt;/p&gt;

&lt;p&gt;unfamiliar_object.methods - ”.methods # … typically 5-20 results&lt;/p&gt;

&lt;p&gt;(unfamiliar_object.methods - ”.methods).sort # … in alphabetical order&lt;br/&gt;&lt;/p&gt;</description><link>http://code.samsm.com/post/43764</link><guid>http://code.samsm.com/post/43764</guid><pubDate>Sun, 04 Mar 2007 22:05:36 -0500</pubDate></item><item><title>The best ActiveResource information available is in the README</title><description>&lt;a href="http://svn.rubyonrails.org/rails/trunk/activeresource/README"&gt;The best ActiveResource information available is in the README&lt;/a&gt;</description><link>http://code.samsm.com/post/41123</link><guid>http://code.samsm.com/post/41123</guid><pubDate>Sun, 04 Mar 2007 15:32:36 -0500</pubDate></item><item><title> :status =&gt; 422 is essential for handling errors with ActiveResource, though it's not included in scaffold_resource.</title><description>&lt;textarea name="code" class="ruby" cols="60" rows="20"&gt;respond_to do |format| 
  format.xml  { render :xml =&gt; @repository.errors.to_xml, :status =&gt; 422 }
end
&lt;/textarea&gt;&lt;br/&gt;</description><link>http://code.samsm.com/post/41080</link><guid>http://code.samsm.com/post/41080</guid><pubDate>Sun, 04 Mar 2007 15:21:02 -0500</pubDate></item></channel></rss>
