<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Rails Rant</title>
	<atom:link href="http://johnmcaliley.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://johnmcaliley.wordpress.com</link>
	<description>My experience with Rails, Mongrel, Nginx, MySQL, etc..</description>
	<lastBuildDate>Tue, 20 Apr 2010 03:11:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='johnmcaliley.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Rails Rant</title>
		<link>http://johnmcaliley.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://johnmcaliley.wordpress.com/osd.xml" title="Rails Rant" />
	<atom:link rel='hub' href='http://johnmcaliley.wordpress.com/?pushpress=hub'/>
		<item>
		<title>star symbol in front of Ruby def argument</title>
		<link>http://johnmcaliley.wordpress.com/2010/04/20/star-symbol-in-front-of-ruby-def-argument/</link>
		<comments>http://johnmcaliley.wordpress.com/2010/04/20/star-symbol-in-front-of-ruby-def-argument/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 03:08:54 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://railsrant.com/?p=255</guid>
		<description><![CDATA[you may have seen something like this and wondered what the star symbol inside the argument parenthesis was: def some_method(*args) #cowboy code goes here end The star symbol in front of args means that this method can accept an unlimited number of arguments. This is commonly used in Ruby on Rails when extracting options from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=255&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>you may have seen something like this and wondered what the star symbol inside the argument parenthesis was:</p>
<div class="codeblock">
<pre>
def some_method(*args)
  #cowboy code goes here
end
</pre>
</div>
<p>The star symbol in front of args means that this method can accept an unlimited number of arguments.  This is commonly used in Ruby on Rails when extracting options from the method arguments:</p>
<div class="codeblock">
options = args.extract_options!
</div>
<p>extract_options! is an ActiveSupport method that pulls out the option hashes from the method arguments.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnmcaliley.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnmcaliley.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnmcaliley.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnmcaliley.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/johnmcaliley.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/johnmcaliley.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/johnmcaliley.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/johnmcaliley.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnmcaliley.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnmcaliley.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnmcaliley.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnmcaliley.wordpress.com/255/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnmcaliley.wordpress.com/255/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnmcaliley.wordpress.com/255/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=255&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://johnmcaliley.wordpress.com/2010/04/20/star-symbol-in-front-of-ruby-def-argument/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fed6c4b838035b8e6b63ca2919c46c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">John</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby &#8211; cattr_accessor vs attr_accessor</title>
		<link>http://johnmcaliley.wordpress.com/2010/04/20/ruby-cattr_accessor-vs-attr_accessor/</link>
		<comments>http://johnmcaliley.wordpress.com/2010/04/20/ruby-cattr_accessor-vs-attr_accessor/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 02:35:56 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://railsrant.com/?p=253</guid>
		<description><![CDATA[What is the difference in these two. You see attr_accessor alot more than cattr_accessor. I actually just stumbled upon it while trying to understand the ActiveRecord code. Apparently, cattr_accessor is class level equivalent of attr_accessor. So cattr_accessor operates at the class level, while attr_accessor operates at the instance level. Here is an example using a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=253&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>What is the difference in these two.  You see attr_accessor alot more than cattr_accessor.  I actually just stumbled upon it while trying to understand the ActiveRecord code.  </p>
<p>Apparently, cattr_accessor is class level equivalent of attr_accessor.  So cattr_accessor operates at the class level, while attr_accessor operates at the instance level.</p>
<p>Here is an example using a Counter class:</p>
<div class="codeblock">
<pre>
class Counter
  cattr_accessor :class_count
  attr_accessor :instance_count
end

counter1 = Counter.new
counter1.instance_count = 1
counter1.class_count = 1

counter2 = Counter.new
p counter2.instance_count
#&gt; nil
p counter2.class_count
#&gt; 1
</pre>
</div>
<p>As you can see the cattr_accessor stays the same for every instance, while the attr_accessor is only on the instance of the class.</p>
<p>Behind the scenes it is just using class and instance variables for the getter/setter methods<br />
@@class_count<br />
@instance_count</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnmcaliley.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnmcaliley.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnmcaliley.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnmcaliley.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/johnmcaliley.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/johnmcaliley.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/johnmcaliley.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/johnmcaliley.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnmcaliley.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnmcaliley.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnmcaliley.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnmcaliley.wordpress.com/253/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnmcaliley.wordpress.com/253/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnmcaliley.wordpress.com/253/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=253&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://johnmcaliley.wordpress.com/2010/04/20/ruby-cattr_accessor-vs-attr_accessor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fed6c4b838035b8e6b63ca2919c46c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">John</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby on Rails dynamic finder &#8211; find_or_create method</title>
		<link>http://johnmcaliley.wordpress.com/2010/04/20/ruby-on-rails-dynamic-finder-find_or_create-method/</link>
		<comments>http://johnmcaliley.wordpress.com/2010/04/20/ruby-on-rails-dynamic-finder-find_or_create-method/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 02:18:34 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://railsrant.com/?p=248</guid>
		<description><![CDATA[Here is another one I was not aware of. I knew you could use dynamic finders to look for one or more attributes, but I did not realize you could do a find and create at the same time (well.. not really both of them at once, but you know what I mean) Blog.find_or_create_by_title(&#8220;Some Blog&#8221;) [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=248&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is another one I was not aware of.  I knew you could use dynamic finders to look for one or more attributes, but I did not realize you could do a find and create at the same time (well.. not really both of them at once, but you know what I mean)</p>
<div class="codeblock">
Blog.find_or_create_by_title(&#8220;Some Blog&#8221;)
</div>
<p>If there is a blog with title = &#8220;Some Blog&#8221;, then it will pull this blog out of the table.  If the blog does not exist, a new Blog is created with the title &#8220;Some Blog&#8221;.  Alternately you can use find_or_initialize_by_name and it will not save the object to the database immediately.. it will be available in the scope of your code, just as if you called blog = Blog.new(:title=&gt;&#8221;Some Blog&#8221;)</p>
<p>This could come in handy in certain situations and save you a line of code.  Daddy like</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnmcaliley.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnmcaliley.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnmcaliley.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnmcaliley.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/johnmcaliley.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/johnmcaliley.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/johnmcaliley.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/johnmcaliley.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnmcaliley.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnmcaliley.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnmcaliley.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnmcaliley.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnmcaliley.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnmcaliley.wordpress.com/248/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=248&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://johnmcaliley.wordpress.com/2010/04/20/ruby-on-rails-dynamic-finder-find_or_create-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fed6c4b838035b8e6b63ca2919c46c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">John</media:title>
		</media:content>
	</item>
		<item>
		<title>Overriding Rails ActiveRecord object getter/setter fields</title>
		<link>http://johnmcaliley.wordpress.com/2010/04/20/overriding-rails-activerecord-object-fields/</link>
		<comments>http://johnmcaliley.wordpress.com/2010/04/20/overriding-rails-activerecord-object-fields/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 02:08:57 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://railsrant.com/?p=245</guid>
		<description><![CDATA[Lets say you have a widget model in Ruby on Rails.  Your database table contains a field called &#8220;name&#8221;.  Let&#8217;s say you want to add something to this field in your model.  You need a specialized def in order to do this.. you need to use write_attribute and read_attribute methods. Here is an example where [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=245&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Lets say you have a widget model in Ruby on Rails.  Your database table contains a field called &#8220;name&#8221;.  Let&#8217;s say you want to add something to this field in your model.  You need a specialized def in order to do this.. you need to use write_attribute and read_attribute methods.</p>
<p>Here is an example where I override the Rails ActiveRecord model attribute setter.  This will append a test string onto the name:</p>
<div class="codeblock">
<pre>
class Widget &lt; ActiveRecord::Base
  def name=(name)
    write_attribute(:name,&quot;#{name} - test&quot;)
  end
end
</pre>
</div>
<p>You can also do this with the read_attribute method and it works the opposite way&#8230; instead of operating on the setter, you operate on the getter.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnmcaliley.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnmcaliley.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnmcaliley.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnmcaliley.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/johnmcaliley.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/johnmcaliley.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/johnmcaliley.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/johnmcaliley.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnmcaliley.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnmcaliley.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnmcaliley.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnmcaliley.wordpress.com/245/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnmcaliley.wordpress.com/245/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnmcaliley.wordpress.com/245/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=245&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://johnmcaliley.wordpress.com/2010/04/20/overriding-rails-activerecord-object-fields/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fed6c4b838035b8e6b63ca2919c46c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">John</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL IN &#8211; Do it in Rails find using an array</title>
		<link>http://johnmcaliley.wordpress.com/2010/04/20/sql-in-command-in-rails-find-using-an-array/</link>
		<comments>http://johnmcaliley.wordpress.com/2010/04/20/sql-in-command-in-rails-find-using-an-array/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 01:53:08 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby on rails]]></category>

		<guid isPermaLink="false">http://railsrant.com/?p=240</guid>
		<description><![CDATA[I thought this was pretty cool and a little more elegant than using a string, which I have been doing before I saw this. In SQL you can do a command like so: SELECT * FROM widgets WHERE id IN (1,2,3,4,5); I was doing this before: Widget.find(:all,:conditions=&#62;&#8221;id in (1,2,3,4,5)&#8221;) Instead of doing this you can [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=240&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I thought this was pretty cool and a little more elegant than using a string, which I have been doing before I saw this.  In SQL you can do a command like so:</p>
<div class="codeblock">SELECT * FROM widgets WHERE id IN (1,2,3,4,5);</div>
<p>I was doing this before:</p>
<div class="codeblock">Widget.find(:all,:conditions=&gt;&#8221;id in (1,2,3,4,5)&#8221;)</div>
<p>Instead of doing this you can use an array instead of a string:</p>
<div class="codeblock">Widget.find(:all,:conditions=&gt; {:id =&gt; [1,2,3,4,5])</div>
<p>That looks better.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnmcaliley.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnmcaliley.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnmcaliley.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnmcaliley.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/johnmcaliley.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/johnmcaliley.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/johnmcaliley.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/johnmcaliley.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnmcaliley.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnmcaliley.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnmcaliley.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnmcaliley.wordpress.com/240/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnmcaliley.wordpress.com/240/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnmcaliley.wordpress.com/240/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=240&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://johnmcaliley.wordpress.com/2010/04/20/sql-in-command-in-rails-find-using-an-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fed6c4b838035b8e6b63ca2919c46c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">John</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby programming &#8211; what is dollar sign colon .unshift ($:.unshift) ??</title>
		<link>http://johnmcaliley.wordpress.com/2010/04/19/ruby-programming-what-is-dollar-sign-colon-unshift-unshift/</link>
		<comments>http://johnmcaliley.wordpress.com/2010/04/19/ruby-programming-what-is-dollar-sign-colon-unshift-unshift/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 19:09:30 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[special variables]]></category>

		<guid isPermaLink="false">http://railsrant.com/?p=221</guid>
		<description><![CDATA[This is a special variable in ruby. Ruby special variables start with the dollar sign followed by a single character. This particular variable is the default search path for load or require. If you call it in irb or the rails console, you can see it returns an array of strings which are paths. Since [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=221&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a special variable in ruby.  Ruby special variables start with the dollar sign followed by a single character.  This particular variable is the default search path for <em>load</em> or <em>require</em>.  If you call it in irb or the rails console, you can see it returns an array of strings which are paths.</p>
<p>Since it returns an array, the unshift is simply an array method that adds an object to the beginning of an array.</p>
<p>An example of this can be seen in the ActiveRecord source (2.3.2 rails).  In this particular example, the ActiveSupport path is prepended to the array, so that it can be required in the code.</p>
<div class="codeblock">
<pre>
activesupport_path = "#{File.dirname(__FILE__)}/../../activesupport/lib"
if File.directory?(activesupport_path)
  $:.unshift activesupport_path
  require 'active_support'
end</pre>
</div>
<p>There are a bunch of other special variables in ruby like this one.  Take a look here for more info: <a href="http://www.zenspider.com/Languages/Ruby/QuickRef.html#18">http://www.zenspider.com/Languages/Ruby/QuickRef.html#18</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnmcaliley.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnmcaliley.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnmcaliley.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnmcaliley.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/johnmcaliley.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/johnmcaliley.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/johnmcaliley.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/johnmcaliley.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnmcaliley.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnmcaliley.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnmcaliley.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnmcaliley.wordpress.com/221/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnmcaliley.wordpress.com/221/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnmcaliley.wordpress.com/221/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=221&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://johnmcaliley.wordpress.com/2010/04/19/ruby-programming-what-is-dollar-sign-colon-unshift-unshift/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fed6c4b838035b8e6b63ca2919c46c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">John</media:title>
		</media:content>
	</item>
		<item>
		<title>MySQL group by day, month or year using a timestamp column</title>
		<link>http://johnmcaliley.wordpress.com/2010/04/19/mysql-group-by-day-month-or-year-using-a-timestamp-column/</link>
		<comments>http://johnmcaliley.wordpress.com/2010/04/19/mysql-group-by-day-month-or-year-using-a-timestamp-column/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 14:59:05 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://railsrant.com/?p=217</guid>
		<description><![CDATA[In Ruby on Rails, created_at and updated_at columns are MySQL timestamp columns.  GROUP BY is pretty useless on a timestamp column, unless you are trying to group rows that were added at the same second.  I needed to group by just the date, so in order to do this I had to manipulate the timestamp [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=217&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In Ruby on Rails, created_at and updated_at columns are MySQL timestamp columns.  GROUP BY is pretty useless on a timestamp column, unless you are trying to group rows that were added at the same second.  I needed to group by just the date, so in order to do this I had to manipulate the timestamp with a MySQL operator.  Using the DATE_FORMAT operator, you can easily group the timestamp column using any format you want.  For my example, I needed to group rows that were added on the same day.  Here is my query:</p>
<div class="codeblock">select count(*), DATE_FORMAT(created_at,&#8221;%Y-%m-%d&#8221;) as created_day FROM widgets GROUP BY created_day</div>
<p>This query will give you something like this:</p>
<div class="codeblock">count(*) | created_day<br />
126 | 2010-04-12<br />
168 | 2010-04-13<br />
169 | 2010-04-14<br />
189 | 2010-04-15<br />
187 | 2010-04-16<br />
13 | 2010-04-17</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnmcaliley.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnmcaliley.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnmcaliley.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnmcaliley.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/johnmcaliley.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/johnmcaliley.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/johnmcaliley.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/johnmcaliley.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnmcaliley.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnmcaliley.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnmcaliley.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnmcaliley.wordpress.com/217/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnmcaliley.wordpress.com/217/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnmcaliley.wordpress.com/217/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=217&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://johnmcaliley.wordpress.com/2010/04/19/mysql-group-by-day-month-or-year-using-a-timestamp-column/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fed6c4b838035b8e6b63ca2919c46c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">John</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby If statements &#8211; all objects are true, except FalseClass (false)</title>
		<link>http://johnmcaliley.wordpress.com/2010/04/15/ruby-if-statements-all-objects-are-true-except-falseclass-false/</link>
		<comments>http://johnmcaliley.wordpress.com/2010/04/15/ruby-if-statements-all-objects-are-true-except-falseclass-false/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 17:35:27 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://railsrant.com/?p=214</guid>
		<description><![CDATA[This was a bit confusing to me since I was used to programming in other languages. Basically every object has a boolean value with is true, unless the object is false or nil. Even the integer 0 will return true if you put it into an &#8220;if&#8221; expression. Take a look at some examples: # [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=214&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This was a bit confusing to me since I was used to programming in other languages.  Basically every object has a boolean value with is true, unless the object is false or nil.  Even the integer 0 will return true if you put it into an &#8220;if&#8221; expression.  Take a look at some examples:</p>
<div class="codeblock">
<pre># STRING TEST
if "test"
  p "true"
else
  p "false"
end
=&gt;"true"

#FIXNUM TEST
if 0
  p "true"
else
  p "false"
end
=&gt;"true"

#FalseClass TEST
if false
  p "true"
else
  p "false"
end
=&gt;"false"

#NIL TEST
if nil
  p "true"
else
  p "false"
end
=&gt;"false"
</pre>
</div>
<p>I find this logic especially useful when passing an options hash inside a function.  It allows you to use an if expression on the option and it will always return true, unless that object is nil or has been set to false.  This allows you to test if an option exists by writing only:</p>
<div class="codeblock">
<pre>if option[:some_option]
  # do something
end
</pre>
</div>
<p>Anyways.. I just thought that was a pretty cool feature, compared to other languages</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnmcaliley.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnmcaliley.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnmcaliley.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnmcaliley.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/johnmcaliley.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/johnmcaliley.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/johnmcaliley.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/johnmcaliley.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnmcaliley.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnmcaliley.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnmcaliley.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnmcaliley.wordpress.com/214/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnmcaliley.wordpress.com/214/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnmcaliley.wordpress.com/214/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=214&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://johnmcaliley.wordpress.com/2010/04/15/ruby-if-statements-all-objects-are-true-except-falseclass-false/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fed6c4b838035b8e6b63ca2919c46c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">John</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruport error &#8211; undefined local variable or method `acts_as_reportable&#8217;</title>
		<link>http://johnmcaliley.wordpress.com/2010/04/06/ruport-error-undefined-local-variable-or-method-acts_as_reportable/</link>
		<comments>http://johnmcaliley.wordpress.com/2010/04/06/ruport-error-undefined-local-variable-or-method-acts_as_reportable/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 15:42:24 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://railsrant.com/?p=206</guid>
		<description><![CDATA[I was trying to install ruport by reading some of the sparse tutorials on the web.  It took some trial and error to actually get ActiveRecord to recognize the acts_as_reportable call.  Some of the documentation just said installing ruport was enough, but in my scenario I found that you also have to install acts_as_reportable as [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=206&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was trying to install ruport by reading some of the sparse tutorials on the web.  It took some trial and error to actually get ActiveRecord to recognize the acts_as_reportable call.   Some of the documentation just said installing ruport was enough, but in my scenario I found that you also have to install acts_as_reportable as a seperate gem.  Maybe Ruport is not including that in the lateset version??  I am nots ure.. didn&#8217;t really look at the latest commits to the code.</p>
<p>Here is what I had to do:<br />
1. gem install ruport<br />
2. gem install acts_as_reportable<br />
3. put this in your environment.rb inside the initializer</p>
<div class="codeblock">
<pre>
Rails::Initializer.run do |config|
  ...
  require "ruport"
  require "ruport/acts_as_reportable"
  ...
end
</pre>
</div>
<p>That should do the trick and Rails will recognize acts_as_reportable.</p>
<p>UPDATE:  After a closer look at the documentation, this was already metioned -&gt; http://ruportbook.com/acts_as_reportable.html<br />
Thanks Andrew!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnmcaliley.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnmcaliley.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnmcaliley.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnmcaliley.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/johnmcaliley.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/johnmcaliley.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/johnmcaliley.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/johnmcaliley.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnmcaliley.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnmcaliley.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnmcaliley.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnmcaliley.wordpress.com/206/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnmcaliley.wordpress.com/206/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnmcaliley.wordpress.com/206/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=206&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://johnmcaliley.wordpress.com/2010/04/06/ruport-error-undefined-local-variable-or-method-acts_as_reportable/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fed6c4b838035b8e6b63ca2919c46c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">John</media:title>
		</media:content>
	</item>
		<item>
		<title>Testing email with sendmail using the command line</title>
		<link>http://johnmcaliley.wordpress.com/2010/04/05/testing-email-with-sendmail-using-the-command-line/</link>
		<comments>http://johnmcaliley.wordpress.com/2010/04/05/testing-email-with-sendmail-using-the-command-line/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 15:35:36 +0000</pubDate>
		<dc:creator>John</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://railsrant.com/?p=197</guid>
		<description><![CDATA[This is pretty easy to do.  First create a file with your subject and body in it.  I will call it email.test Subject: Testing some email this is my message &#60;blank line&#62; of course you dont actually write &#60;blank line&#62;.  Just hit enter/return after the message body, so it adds a blank line. Then you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=197&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is pretty easy to do.  First create a file with your subject and body in it.  I will call it email.test</p>
<div style="background-color:#eee;border:1px solid #aaa;padding:10px;">Subject: Testing some email<br />
this is my message<br />
&lt;blank line&gt;</div>
<p>of course you dont actually write &lt;blank line&gt;.  Just hit enter/return after the message body, so it adds a blank line.</p>
<p>Then you send the email using this command.  The -v option makes it verbose, so you can see whats going on.</p>
<div style="background-color:#eee;border:1px solid #aaa;padding:10px;">&gt;/usr/sbin/sendmail -v my@address.com &lt; email.test</div>
<p>Note: your sendmail executable might be located somewhere other than /usr/sbin/sendmail.  Its most likely in a /bin or /sbin directory.  You can search for it using:</p>
<div style="background-color:#eee;border:1px solid #aaa;padding:10px;">
find / -name sendmail
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/johnmcaliley.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/johnmcaliley.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/johnmcaliley.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/johnmcaliley.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/johnmcaliley.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/johnmcaliley.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/johnmcaliley.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/johnmcaliley.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/johnmcaliley.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/johnmcaliley.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/johnmcaliley.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/johnmcaliley.wordpress.com/197/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/johnmcaliley.wordpress.com/197/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/johnmcaliley.wordpress.com/197/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=johnmcaliley.wordpress.com&amp;blog=8964095&amp;post=197&amp;subd=johnmcaliley&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://johnmcaliley.wordpress.com/2010/04/05/testing-email-with-sendmail-using-the-command-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fed6c4b838035b8e6b63ca2919c46c6?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">John</media:title>
		</media:content>
	</item>
	</channel>
</rss>
