<?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>Sean&#039;s Blog &#187; Ruby on Rails</title>
	<atom:link href="http://seanbehan.com/category/ruby-on-rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Web Programming, Ruby on Rails, Wordpress, PHP from Burlington, Vermont</description>
	<lastBuildDate>Wed, 18 Jan 2012 21:44:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>How to Add Additional Sub Directories to the Default Rails Test:Unit File Structure</title>
		<link>http://seanbehan.com/ruby-on-rails/how-to-add-additional-sub-directories-to-the-default-rails-testunit-file-structure/</link>
		<comments>http://seanbehan.com/ruby-on-rails/how-to-add-additional-sub-directories-to-the-default-rails-testunit-file-structure/#comments</comments>
		<pubDate>Wed, 18 Jan 2012 21:44:54 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rake]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[setup]]></category>
		<category><![CDATA[sub directories]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1496</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Fhow-to-add-additional-sub-directories-to-the-default-rails-testunit-file-structure%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="How to Add Additional Sub Directories to the Default Rails Test:Unit File Structure" data-url="http://seanbehan.com/ruby-on-rails/how-to-add-additional-sub-directories-to-the-default-rails-testunit-file-structure/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p><script src="https://gist.github.com/1635859.js"> </script></p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/how-to-add-additional-sub-directories-to-the-default-rails-testunit-file-structure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Color Output with Test:Unit, AutoTest and Ruby 1.9</title>
		<link>http://seanbehan.com/ruby/color-output-with-testunit-autotest-and-ruby-1-9/</link>
		<comments>http://seanbehan.com/ruby/color-output-with-testunit-autotest-and-ruby-1-9/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 19:31:52 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[autotest]]></category>
		<category><![CDATA[color]]></category>
		<category><![CDATA[hacks]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[workarounds]]></category>
		<category><![CDATA[workflow]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1486</guid>
		<description><![CDATA[If you are testing using Test:Unit (rather than RSpec) and you&#8217;re using Ruby 1.9.* colorized output of your tests using Autotest will not be immediately available. Since, 1.9 comes with mini test the test/unit/ui/console/testrunner.rb script is not loaded and not available and will break your tests. The solution is to require Test:Unit version 2.0.0 in [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby%2Fcolor-output-with-testunit-autotest-and-ruby-1-9%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Color Output with Test:Unit, AutoTest and Ruby 1.9" data-url="http://seanbehan.com/ruby/color-output-with-testunit-autotest-and-ruby-1-9/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>If you are testing using Test:Unit (rather than RSpec) and you&#8217;re using Ruby 1.9.* colorized output of your tests using Autotest will not be immediately available. Since, 1.9 comes with mini test the test/unit/ui/console/testrunner.rb script is not loaded and not available and will break your tests. </p>
<p>The solution is to require Test:Unit version 2.0.0 in your Gemfile, require the testrunner.rb script in test/test_helper.rb and reopen and implement the guess_color_availability method. </p>
<p><script src="https://gist.github.com/1575327.js"> </script></p>
<p>Then you can just run the autotest command (or bundle exec autotest) from your project directory. When you save a file your tests will be run for the file that has been changed and the results will be fully colorized!</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby/color-output-with-testunit-autotest-and-ruby-1-9/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Aliasing Attributes in Ruby on Rails</title>
		<link>http://seanbehan.com/ruby-on-rails/aliasing-attributes-in-ruby-on-rails/</link>
		<comments>http://seanbehan.com/ruby-on-rails/aliasing-attributes-in-ruby-on-rails/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 17:13:10 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[aliasing]]></category>
		<category><![CDATA[quick tips]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1417</guid>
		<description><![CDATA[Alias an attribute with alias_attribute method. The first argument is the name for the new attribute, while the second argument is to identify the attribute that is already defined. class User &#60; ActiveRecord::Base alias_attribute :username, :login end]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Faliasing-attributes-in-ruby-on-rails%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Aliasing Attributes in Ruby on Rails" data-url="http://seanbehan.com/ruby-on-rails/aliasing-attributes-in-ruby-on-rails/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Alias an attribute with alias_attribute method. </p>
<p>The first argument is the name for the new attribute, while the second argument is to identify the attribute that is already defined. </p>
<pre class="wp-code-highlight prettyprint">
class User &lt; ActiveRecord::Base
  alias_attribute :username, :login
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/aliasing-attributes-in-ruby-on-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails 3 Config Auto Load Paths in Application.rb</title>
		<link>http://seanbehan.com/ruby-on-rails/rails-3-config-auto-load-paths-in-application-rb/</link>
		<comments>http://seanbehan.com/ruby-on-rails/rails-3-config-auto-load-paths-in-application-rb/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 17:09:17 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[auto load]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[filepaths]]></category>
		<category><![CDATA[rails 3]]></category>
		<category><![CDATA[rails defaults]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1414</guid>
		<description><![CDATA[In Rails 3 files in lib/ are no longer loaded by default. It&#8217;s a snap to auto load these classes by adding the following line to config/application.rb config.autoload_paths += %W(#{config.root}/lib) This is commented out around line 16. Either replace it or uncomment it out to reflect the location where your lib classes are located.]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Frails-3-config-auto-load-paths-in-application-rb%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Rails 3 Config Auto Load Paths in Application.rb" data-url="http://seanbehan.com/ruby-on-rails/rails-3-config-auto-load-paths-in-application-rb/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>In Rails 3 files in lib/ are no longer loaded by default. It&#8217;s a snap to auto load these classes by adding the following line to config/application.rb</p>
<pre class="wp-code-highlight prettyprint">
    config.autoload_paths += %W(#{config.root}/lib)
</pre>
<p>This is commented out around line 16. Either replace it or uncomment it out to reflect the location where your lib classes are located.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/rails-3-config-auto-load-paths-in-application-rb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Send_File in Production Delivers an Empty File</title>
		<link>http://seanbehan.com/ruby-on-rails/rails-send_file-in-production-delivers-an-empty-file/</link>
		<comments>http://seanbehan.com/ruby-on-rails/rails-send_file-in-production-delivers-an-empty-file/#comments</comments>
		<pubDate>Tue, 14 Jun 2011 15:54:06 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[gotchas]]></category>
		<category><![CDATA[mishaps]]></category>
		<category><![CDATA[production]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[send_file]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1370</guid>
		<description><![CDATA[If you&#8217;re running Rails in production it will by default be configured to let apache or nginx send files for you. If you&#8217;re handling file downloads yourself with send_file send_file(&#34;path/to/file.txt&#34;) you will notice that the downloaded files are empty. To get around this just comment out the following in your config/environments/production.rb file. # comment out [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Frails-send_file-in-production-delivers-an-empty-file%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Rails Send_File in Production Delivers an Empty File" data-url="http://seanbehan.com/ruby-on-rails/rails-send_file-in-production-delivers-an-empty-file/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>If you&#8217;re running Rails in production it will by default be configured to let apache or nginx send files for you. If you&#8217;re handling file downloads yourself with send_file</p>
<pre class="wp-code-highlight prettyprint">
send_file(&quot;path/to/file.txt&quot;)
</pre>
<p>you will notice that the downloaded files are empty. To get around this just comment out the following in your config/environments/production.rb file.</p>
<pre class="wp-code-highlight prettyprint">
  # comment out for production because apache/nginx are not doing this for us
  #config.action_dispatch.x_sendfile_header = &quot;X-Sendfile&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/rails-send_file-in-production-delivers-an-empty-file/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rails Find All by Birthday: How to Find Upcoming Birthdays with ActiveRecord</title>
		<link>http://seanbehan.com/ruby-on-rails/rails-find-all-by-birthday-how-to-find-upcoming-birthdays-with-activerecord/</link>
		<comments>http://seanbehan.com/ruby-on-rails/rails-find-all-by-birthday-how-to-find-upcoming-birthdays-with-activerecord/#comments</comments>
		<pubDate>Sun, 12 Jun 2011 21:34:02 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[active record]]></category>
		<category><![CDATA[activerecord]]></category>
		<category><![CDATA[birthdays]]></category>
		<category><![CDATA[cache counter]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[how to]]></category>
		<category><![CDATA[scopes]]></category>
		<category><![CDATA[timestamp]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1355</guid>
		<description><![CDATA[There are a few ways to solve this problem. However, I think the easiest is to cache the day of the year that the user is born on as an integer. If stored alongside the timestamp we can quickly get a list but properly handle the full birthday elsewhere, such as in the view. You [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Frails-find-all-by-birthday-how-to-find-upcoming-birthdays-with-activerecord%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Rails Find All by Birthday: How to Find Upcoming Birthdays with ActiveRecord" data-url="http://seanbehan.com/ruby-on-rails/rails-find-all-by-birthday-how-to-find-upcoming-birthdays-with-activerecord/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>There are a few ways to solve this problem. However, I think the easiest is to cache the day of the year that the user is born on as an integer. If stored alongside the timestamp we can quickly get a list but properly handle the full birthday elsewhere, such as in the view. You don&#8217;t want to rely on just the cached day of year because leap year is not accounted for. </p>
<p>The model will need both born_at and birthday columns. </p>
<pre class="wp-code-highlight prettyprint">
create_table :users do |t|
  t.timestamp :born_at  # full timestamp
  t.integer :birthday 	# just the day of year
end
</pre>
<p>The user model also needs a callback (before_save) to set and or update the cached birthday column based on the full timestamp. For convenience, a named scope can be added to the model which will let you call User.birthdays. </p>
<pre class="wp-code-highlight prettyprint">
class User
  # User.birthdays
  scope :birthdays, lambda { where('birthday in(?)', 7.times.map{|i| Time.now.yday + i}) }

  def before_save
  	self.birthday = born_at.yday
  end
end
</pre>
<p>You could also use the week in year (1 &#8211; 52) for the cache. Using the day you can look an arbitrary number of days ahead.</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/rails-find-all-by-birthday-how-to-find-upcoming-birthdays-with-activerecord/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple String Concatenation of a Collection Written as a Helper for Rails</title>
		<link>http://seanbehan.com/ruby-on-rails/simple-string-concatenation-of-a-collection-written-as-a-helper-for-rails/</link>
		<comments>http://seanbehan.com/ruby-on-rails/simple-string-concatenation-of-a-collection-written-as-a-helper-for-rails/#comments</comments>
		<pubDate>Tue, 24 May 2011 02:23:17 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[bookmarks]]></category>
		<category><![CDATA[buffer]]></category>
		<category><![CDATA[collection]]></category>
		<category><![CDATA[content_tag]]></category>
		<category><![CDATA[excerpt]]></category>
		<category><![CDATA[helper methods]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[visual markup]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1316</guid>
		<description><![CDATA[At Railsconf last week I took Greg Pollack&#8217;s online course Rails Best Practices. The interface is gorgeous and the instructions are excellent. One of the lessons involved taking a partial and moving it into a helper. I was reminded how difficult such a simple task can be. I have written about this before Yield a [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Fsimple-string-concatenation-of-a-collection-written-as-a-helper-for-rails%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Simple String Concatenation of a Collection Written as a Helper for Rails" data-url="http://seanbehan.com/ruby-on-rails/simple-string-concatenation-of-a-collection-written-as-a-helper-for-rails/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>At Railsconf last week I took Greg Pollack&#8217;s online course <a href="http://www.codeschool.com/courses/rails-best-practices">Rails Best Practices</a>. The interface is gorgeous and the instructions are excellent. One of the lessons involved taking a partial and moving it into a helper. I was reminded how difficult such a simple task can be. I have written about this before <a href="http://seanbehan.com/programming/yield-a-block-within-rails-helper-method-with-multiple-content_tags-using-concat/">Yield a Block Within Rails Helper Method with Multiple Content Tags</a>. However, that post aims to solve a slightly different problem, where the helper method takes the captured text from a block passed as an argument which essentially acts as a wrapper.  </p>
<p>The difficulty isn&#8217;t with the logic itself and or the complexity/verbosity that the code is likely to produce. Rather, it is difficult because you have to endlessly concatenate strings and this something somewhat uncommon when programming with ruby. We have to remember that we&#8217;re working with a buffer of text about to be flushed. Here is a simple code snippet that shows how to write a helper method that loops over a collection of objects. </p>
<pre class="wp-code-highlight prettyprint">
  def bookmarks_for(user=nil)
    content_tag(:div, :id =&gt; &quot;bookmarks&quot;) do
      user.bookmarks.each do |bookmark|
        concat(
          content_tag(:strong) { bookmark.member_name } +
          excerpt(bookmark.body, '', 100)
        )
      end.join
    end
  end
</pre>
<p>Notice the use of the concat() method the &#8220;+&#8221; sugb and .join() method. All three of which bring these statements together into one final piece of html called in the view. </p>
<pre class="wp-code-highlight prettyprint">
&lt;%= bookmarks_for(@user) %&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/simple-string-concatenation-of-a-collection-written-as-a-helper-for-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reusing Scopes (Formerly Named_scope) In Rails 3</title>
		<link>http://seanbehan.com/ruby-on-rails/reusing-scopes-formerly-named_scope-in-rails-3/</link>
		<comments>http://seanbehan.com/ruby-on-rails/reusing-scopes-formerly-named_scope-in-rails-3/#comments</comments>
		<pubDate>Thu, 05 May 2011 13:22:03 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[active record]]></category>
		<category><![CDATA[models]]></category>
		<category><![CDATA[named scopes]]></category>
		<category><![CDATA[scopes]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1296</guid>
		<description><![CDATA[You can easily chain scopes together in your models. class Article < ActiveRecord::Base scope :ordered, order('position ASC') scope :published, ordered.where('published = ?', true) scope :for_homepage, published.limit(3) end Article.for_homepage.to_sql # => SELECT \"articles\".* FROM \"articles\" WHERE (published = 't') ORDER BY position LIMIT 3]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Freusing-scopes-formerly-named_scope-in-rails-3%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Reusing Scopes (Formerly Named_scope) In Rails 3" data-url="http://seanbehan.com/ruby-on-rails/reusing-scopes-formerly-named_scope-in-rails-3/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>You can easily chain scopes together in your models.<br />
<code><br />
class Article < ActiveRecord::Base<br />
  scope :ordered, order('position ASC')<br />
  scope :published, ordered.where('published = ?', true)<br />
  scope :for_homepage, published.limit(3)<br />
end<br />
</code></p>
<p><code><br />
Article.for_homepage.to_sql<br />
# => SELECT \"articles\".* FROM \"articles\" WHERE (published = 't') ORDER BY position LIMIT 3<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/reusing-scopes-formerly-named_scope-in-rails-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing Ruby on Rails 3, MySQL, Git, Ruby Enterprise Edition, Passenger (Mod_Rails) on Ubuntu with Rackspace Cloud.</title>
		<link>http://seanbehan.com/ruby-on-rails/installing-ruby-on-rails-3-mysql-git-ruby-enterprise-edition-passenger-mod_rails-on-ubuntu-with-rackspace-cloud/</link>
		<comments>http://seanbehan.com/ruby-on-rails/installing-ruby-on-rails-3-mysql-git-ruby-enterprise-edition-passenger-mod_rails-on-ubuntu-with-rackspace-cloud/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 19:12:46 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[Git]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[rackspace]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby enterprise edition]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1269</guid>
		<description><![CDATA[Short and sweet. Here all the commands I run in this order to set up a brand new box. It usually takes about 10 &#8211; 15 minutes on a 256 MB RAM instance. Compiling Ruby Enterprise Edition, which is super easy, will take the most amount of time. It will seem to have gotten stuck. [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Fruby-on-rails%2Finstalling-ruby-on-rails-3-mysql-git-ruby-enterprise-edition-passenger-mod_rails-on-ubuntu-with-rackspace-cloud%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Installing Ruby on Rails 3, MySQL, Git, Ruby Enterprise Edition, Passenger (Mod_Rails) on Ubuntu with Rackspace Cloud." data-url="http://seanbehan.com/ruby-on-rails/installing-ruby-on-rails-3-mysql-git-ruby-enterprise-edition-passenger-mod_rails-on-ubuntu-with-rackspace-cloud/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>Short and sweet. Here all the commands I run in this order to set up a brand new box. It usually takes about 10 &#8211; 15 minutes on a 256 MB RAM instance. Compiling Ruby Enterprise Edition, which is super easy, will take the most amount of time. It will seem to have gotten stuck. It hasn&#8217;t. It just takes a little while. </p>
<pre class="wp-code-highlight prettyprint">
# Update, upgrade and install all necessary packages for Ruby on Rails server if you've got a fresh Ubuntu slice
apt-get update
apt-get upgrade

apt-get install build-essential patch libssl-dev libreadline5-dev

apt-get install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby imagemagick librmagick-ruby1.8 librmagick-ruby-doc libfreetype6-dev xml-core postfix
# postfix will prompt you for details
# use Internet Site and enter in the domain name you are planning on sending email from 

apt-get install apache2 apache2-prefork-dev libapr1-dev libaprutil1-dev libcurl4-openssl-dev git-core mysql-server mysql-client libmysqlclient15-dev libmysql-ruby
# mysql will also prompt you to set up a root user account. set the password to be anything you like

# next, download the latest release of ruby enterprise edition but when you're installing it on your own machine version numbers and release dates may have changed.
# pay attention to the version and release date before the file extension. it will be something like
# ... 1.8.7-2010.02
# this will change to something like 2011.03, 2011.04... etc in the future.
# just double check the paths on when you are installing and make the necessary substitutions

# ruby enterprise edition is available at http://www.rubyenterpriseedition.com/download.html
wget http://rubyforge.org/frs/download.php/71096/ruby-enterprise-1.8.7-2010.02.tar.gz
tar xzvf ruby-enterprise-1.8.7-2010.02.tar.gz 

./ruby-enterprise-1.8.7-2010.02/installer
# this may take a little while (just follow the instructions)
# and hit enter to install in default location (recommended) when prompted 

# and to install passenger (which is mod_rails for apache)
/opt/ruby-enterprise-1.8.7-2010.02/bin/passenger-install-apache2-module 

# i take the output from the above script and add it to my available modules directory
vim /etc/apache2/mods-available/passenger.conf

# and enter something like this in the newly created file (your version numbers will prob. be different)
LoadModule passenger_module /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/passenger-3.0.2/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby-enterprise-1.8.7-2010.02/lib/ruby/gems/1.8/gems/passenger-3.0.2
PassengerRuby /opt/ruby-enterprise-1.8.7-2010.02/bin/ruby

# and then sym link it to the enabled directory so that apache knows about it
ln -s /etc/apache2/mods-available/passenger.conf /etc/apache2/mods-enabled/passenger.conf

# and now i want to include ruby enterprise edition in my path so i add it to my profile (again make sure the path is correct)
vim /etc/profile.d/passenger.sh
export PATH=/opt/ruby-enterprise-1.8.7-2010.02/bin:$PATH

. /etc/profile.d/passenger.sh
# the &quot;.&quot; file will make the setting available for the current terminal session
rails -v
ruby -v
rake -v
# should all be working now
# and
which ruby
# should point to the ruby enterprise edition under /opt

# next i
# set up public/private keys
# so i can do
# ssh localhost without using a password
cd
test -e ~/.ssh/id_dsa.pub || ssh-keygen -t dsa
cat ~/.ssh/id_dsa.pub &gt;&gt; ~/.ssh/authorized_keys2

# and finally install git
apt-get install git-core
</pre>
<p>You should now have a server ready to server ruby on rails applications!</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/installing-ruby-on-rails-3-mysql-git-ruby-enterprise-edition-passenger-mod_rails-on-ubuntu-with-rackspace-cloud/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rails 3 disable_with Does Not Work with Ajax Remote Form_for</title>
		<link>http://seanbehan.com/front-end-development/rails-3-disable_with-does-not-work-with-ajax-remote-form_for/</link>
		<comments>http://seanbehan.com/front-end-development/rails-3-disable_with-does-not-work-with-ajax-remote-form_for/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 17:40:50 +0000</pubDate>
		<dc:creator>bseanvt</dc:creator>
				<category><![CDATA[Front End Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[disable_with]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails 3]]></category>
		<category><![CDATA[rails helpers]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=1267</guid>
		<description><![CDATA[It appears that the :disable_with option on the submit_tag form helper method does not behave as expected with remote forms. I&#8217;m not sure if this is a bug or not. But the fix is pretty straight forward, but perhaps a little difficult to trouble shoot. Using submit_tag inside a remote form &#38;lt;%= submit_tag &#34;Submit&#34;, :disable_with [...]]]></description>
			<content:encoded><![CDATA[<div style="height:33px;" class="really_simple_share robots-nocontent snap_nopreview"><div class="really_simple_share_facebook_like" style="width:px;">
				<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fseanbehan.com%2Ffront-end-development%2Frails-3-disable_with-does-not-work-with-ajax-remote-form_for%2F&amp;layout=button_count&amp;show_faces=false&amp;width=&amp;action=like&amp;colorscheme=light&amp;send=false&amp;height=27" 
						scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:px; height:27px;" allowTransparency="true"></iframe>
				</div><div class="really_simple_share_twitter" style="width:px;">
					<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" 
						data-text="Rails 3 disable_with Does Not Work with Ajax Remote Form_for" data-url="http://seanbehan.com/front-end-development/rails-3-disable_with-does-not-work-with-ajax-remote-form_for/" 
						data-via="" ></a> 
				</div></div>
		<div style="clear:both;"></div><p>It appears that the :disable_with option on the submit_tag form helper method does not behave as expected with remote forms. I&#8217;m not sure if this is a bug or not. But the fix is pretty straight forward, but perhaps a little difficult to trouble shoot. Using submit_tag inside a remote form</p>
<pre class="wp-code-highlight prettyprint">
&amp;lt;%= submit_tag &quot;Submit&quot;, :disable_with =&amp;gt; &quot;Submitting....&quot; %&amp;gt;
</pre>
<p>Will not work.</p>
<p>You have to edit your public/javascripts/rails.js file around line #167</p>
<p>and change</p>
<pre class="wp-code-highlight prettyprint">document.on(&quot;ajax:after&quot;, &quot;form&quot;, function(event, element) {</pre>
<p>to</p>
<pre class="wp-code-highlight prettyprint">document.on(&quot;ajax:complete&quot;, &quot;form&quot;, function(event, element) {</pre>
<p>Then things will behave as expected. This assumes you are using Prototype (rather than jQuery).</p>
]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/front-end-development/rails-3-disable_with-does-not-work-with-ajax-remote-form_for/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

