<?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 Behan&#039;s Blog</title>
	<atom:link href="http://seanbehan.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://seanbehan.com</link>
	<description>Entrepreneur, Ruby on Rails Developer &#38; Songwriter</description>
	<lastBuildDate>Sat, 06 Mar 2010 05:07:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setup Wildcard Subdomain on Localhost for Development Work without /Etc/hosts TomFoolery</title>
		<link>http://seanbehan.com/programming/setup-wildcard-subdomain-on-localhost-for-development-work-without-etchosts-tomfoolery/</link>
		<comments>http://seanbehan.com/programming/setup-wildcard-subdomain-on-localhost-for-development-work-without-etchosts-tomfoolery/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 16:52:17 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[/etc/hosts]]></category>
		<category><![CDATA[127.0.0.1]]></category>
		<category><![CDATA[80]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[domain]]></category>
		<category><![CDATA[hexxie.com]]></category>
		<category><![CDATA[localhost]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[resolve]]></category>
		<category><![CDATA[subdomain]]></category>
		<category><![CDATA[wildcard]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=851</guid>
		<description><![CDATA[Step 1.
Open up your browser and visit http://www.hexxie.com. You can also go to anything.hexxie.com and everything.hexxie.com, which will resolve to your local machine (assuming it&#8217;s localhost at 127.0.0.1). 
How it works
 Super simple. I just pointed hexxie.com and *.hexxie.com to 127.0.0.1, which is everyone&#8217;s localhost address. If you&#8217;re on Rails just append the port number [...]


Related posts:<ol><li><a href='http://seanbehan.com/programming/wildcard-virtualhost-with-apache2/' rel='bookmark' title='Permanent Link: Wildcard VirtualHost with Apache2'>Wildcard VirtualHost with Apache2</a></li>
<li><a href='http://seanbehan.com/programming/sending-email-with-rails-on-mac-os-x-development-environment/' rel='bookmark' title='Permanent Link: Sending eMail with Rails on Mac OS X Development Environment'>Sending eMail with Rails on Mac OS X Development Environment</a></li>
<li><a href='http://seanbehan.com/programming/fixing-mysql-for-rails-2-2-development-on-mac-os-x/' rel='bookmark' title='Permanent Link: Fixing MySQL for Rails 2.2 Development on Mac OS X'>Fixing MySQL for Rails 2.2 Development on Mac OS X</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<h3>Step 1.</h1>
<p>Open up your browser and visit <a href="http://www.hexxie.com">http://www.hexxie.com</a>. You can also go to anything.hexxie.com and everything.hexxie.com, which will resolve to your local machine (assuming it&#8217;s localhost at 127.0.0.1). </p>
<h3>How it works</h3>
<p> Super simple. I just pointed hexxie.com and *.hexxie.com to 127.0.0.1, which is everyone&#8217;s localhost address. If you&#8217;re on Rails just append the port number as usual. http://hexxie.com:3000 or on Django http://hexxie.com:8000. Or you can always fire those guys up on port :80 with sudo ./script/server -p80 for Rails<br />
or sudo django-admin.py runserver 80</p>
<p>To set up your own just configure DNS to point your domain to 127.0.0.1 for the IP address. No more futzing with /etc/hosts </p>
<p>Originally got this tip from <a href="http://tbaggery.com/2010/03/04/smack-a-ho-st.html">http://tbaggery.com/2010/03/04/smack-a-ho-st.html</a> who has created his own service at smackaho.st </p>
<p>The word &#8220;Hexe&#8221; is German for &#8220;Witch&#8221;. I have a dog named &#8220;Hexxie&#8221; after the German word and that is the origin of the domain name hexxie.com, in case you&#8217;re wondering.   </p>


<p>Related posts:<ol><li><a href='http://seanbehan.com/programming/wildcard-virtualhost-with-apache2/' rel='bookmark' title='Permanent Link: Wildcard VirtualHost with Apache2'>Wildcard VirtualHost with Apache2</a></li>
<li><a href='http://seanbehan.com/programming/sending-email-with-rails-on-mac-os-x-development-environment/' rel='bookmark' title='Permanent Link: Sending eMail with Rails on Mac OS X Development Environment'>Sending eMail with Rails on Mac OS X Development Environment</a></li>
<li><a href='http://seanbehan.com/programming/fixing-mysql-for-rails-2-2-development-on-mac-os-x/' rel='bookmark' title='Permanent Link: Fixing MySQL for Rails 2.2 Development on Mac OS X'>Fixing MySQL for Rails 2.2 Development on Mac OS X</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/programming/setup-wildcard-subdomain-on-localhost-for-development-work-without-etchosts-tomfoolery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Onchange Event Fired from Select Field in Rails Form</title>
		<link>http://seanbehan.com/ruby-on-rails/onchange-event-fired-from-select-field-in-rails-form/</link>
		<comments>http://seanbehan.com/ruby-on-rails/onchange-event-fired-from-select-field-in-rails-form/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 15:45:21 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[carmen]]></category>
		<category><![CDATA[countries]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[onchange]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[states]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=840</guid>
		<description><![CDATA[In the view there is a regular Rails form and a javascript function that will be triggered when the country select field is changed. The javascript function will make an ajax request to the country_select url with the country code passed as the id variable, e.g., /country_code/us for the United States. I&#8217;m also using the [...]


Related posts:<ol><li><a href='http://seanbehan.com/programming/using-prototype-to-access-form-data/' rel='bookmark' title='Permanent Link: Using Prototype to Access Form Data'>Using Prototype to Access Form Data</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/extending-rails-form-builders/' rel='bookmark' title='Permanent Link: Extending Rails Form Builders'>Extending Rails Form Builders</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/problem-slash-bug-in-rails-with-attr_accessor-and-datetime-select-fields/' rel='bookmark' title='Permanent Link: Problem slash Bug in Rails with attr_accessor and Datetime Select Fields'>Problem slash Bug in Rails with attr_accessor and Datetime Select Fields</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>In the view there is a regular Rails form and a javascript function that will be triggered when the country select field is changed. The javascript function will make an ajax request to the country_select url with the country code passed as the id variable, e.g., /country_code/us for the United States. I&#8217;m also using the Carmen plugin for this example which will provide a list of countries and their respective states/provinces. Not all countries are full supported. More information on Carmen can be found at <a href="http://autonomousmachine.com/2009/4/1/carmen-a-rails-plugin-for-geographic-names-and-abbreviations">http://autonomousmachine.com/2009/4/1/carmen-a-rails-plugin-for-geographic-names-and-abbreviations</a> and <a href="http://github.com/jim/carmen">http://github.com/jim/carmen</a></p>
<pre>
&lt;%form_for(@model) do |f| %&gt;
&lt;script type="text/javascript" charset="utf-8"&gt;
  function change_state_select(state_code
  {
    new Ajax.Request('/country_select/'+state_code
    {
      method: 'get',
      onSuccess: function(transport) {
        $('state_select').replace(transport.responseText);
      }
    });
  }
 &lt;/script&gt;
 &lt;%= f.select :country,
   Carmen::COUNTRIES,
   {},
   { : onchange =&gt; "change_state_select(this.options[this.selectedIndex].value);" }
%&gt;
&lt;div id='state_select'&gt;&lt;/div&gt;
</pre>
<p>***Note the : onchange should really be one word but an emoticon shows up otherwise <img src='http://seanbehan.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nchange <img src='http://seanbehan.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> ***<br />
Since not all countries are supported I need to execute some conditional logic in the action country_select. If the country is supported I&#8217;ll return a snippet of html containing a select field that my form will use. If the country is not supported I&#8217;ll return a text field so that the user can write in their state/province. </p>
<pre>
class CountrySelectController < ApplicationController
  def country_selecet
      begin
         @states = Carmen::states(params[:id])
      rescue
         @states = nil
      end
      render :partial => "country_select/states"
  end
end
</pre>
<p>In the final partial that is rendered there is either a select field or a text field</p>
<pre>
&lt;div id="state_select"&gt;
  &lt;% if @states.nil? %&gt;
    &lt;%= text_field_tag :model, :state %&gt;
  &lt;% else %&gt;
    &lt;%= select :model, :state, Carmen::states(@states)%&gt;
  &lt;% end %&gt;
&lt;/div&gt;
</pre>


<p>Related posts:<ol><li><a href='http://seanbehan.com/programming/using-prototype-to-access-form-data/' rel='bookmark' title='Permanent Link: Using Prototype to Access Form Data'>Using Prototype to Access Form Data</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/extending-rails-form-builders/' rel='bookmark' title='Permanent Link: Extending Rails Form Builders'>Extending Rails Form Builders</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/problem-slash-bug-in-rails-with-attr_accessor-and-datetime-select-fields/' rel='bookmark' title='Permanent Link: Problem slash Bug in Rails with attr_accessor and Datetime Select Fields'>Problem slash Bug in Rails with attr_accessor and Datetime Select Fields</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/onchange-event-fired-from-select-field-in-rails-form/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Plugin Acts as Taggable on Steriods</title>
		<link>http://seanbehan.com/ruby-on-rails/rails-plugin-acts-as-taggable-on-steriods/</link>
		<comments>http://seanbehan.com/ruby-on-rails/rails-plugin-acts-as-taggable-on-steriods/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 22:46:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[active record]]></category>
		<category><![CDATA[migration]]></category>
		<category><![CDATA[model]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[tags]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=831</guid>
		<description><![CDATA[You can download it here http://github.com/suitmymind/acts-as-taggable-on-steroids as well as read usage info (which is for the most part reprinted here). 

./script/plugin install http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids
./script/generate acts_as_taggable_migration
rake db:migrate

Then in your model 

class Post < ActiveRecord::Base
    acts_as_taggable
 end

And usage is as follows

p = Post.find(:first)
p.tag_list # []
p.tag_list = "Funny, Silly"
p.save
p.tag_list # ["Funny", "Silly"]
p.tag_list.add("Great", "Awful")
p.tag_list.remove("Funny")

#to find...
Post.find_tagged_with('Funny, Silly')
Post.find_tagged_with('Funny, Silly', [...]


Related posts:<ol><li><a href='http://seanbehan.com/ruby-on-rails/acts_as_versioned-rails-plugin/' rel='bookmark' title='Permanent Link: Acts_as_versioned Rails Plugin'>Acts_as_versioned Rails Plugin</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/rails-paperclip-plugin-options-for-attaching-files/' rel='bookmark' title='Permanent Link: Rails Paperclip Plugin Options for Attaching Files'>Rails Paperclip Plugin Options for Attaching Files</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/how-to-use-pretty-urls-with-rails-will_paginate-plugin/' rel='bookmark' title='Permanent Link: How to Use Pretty URLs with Rails will_paginate Plugin'>How to Use Pretty URLs with Rails will_paginate Plugin</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>You can download it here <a href="http://github.com/suitmymind/acts-as-taggable-on-steroids">http://github.com/suitmymind/acts-as-taggable-on-steroids</a> as well as read usage info (which is for the most part reprinted here). </p>
<pre>
./script/plugin install http://svn.viney.net.nz/things/rails/plugins/acts_as_taggable_on_steroids
./script/generate acts_as_taggable_migration
rake db:migrate
</pre>
<p>Then in your model </p>
<pre>
class Post < ActiveRecord::Base
    acts_as_taggable
 end
</pre>
<p>And usage is as follows</p>
<pre>
p = Post.find(:first)
p.tag_list # []
p.tag_list = "Funny, Silly"
p.save
p.tag_list # ["Funny", "Silly"]
p.tag_list.add("Great", "Awful")
p.tag_list.remove("Funny")

#to find...
Post.find_tagged_with('Funny, Silly')
Post.find_tagged_with('Funny, Silly', :match_all => true)
</pre>
<p>To use this in a form and let users enter a comma separated list of tag names... </p>
<pre>
form_for @post do |f|
f.text_field :tag_list
</pre>
<p>And to get a tag cloud</p>
<pre>
  #controller
  class PostController &lt; ApplicationController
    def tag_cloud
      @tags = Post.tag_counts
    end
  end

  # and in view...
  &lt;style&gt;
  .css1 { font-size: 1.0em; }
  .css2 { font-size: 1.2em; }
  .css3 { font-size: 1.4em; }
  .css4 { font-size: 1.6em; }
  &lt;/style&gt;

  &lt;% tag_cloud @tags, %w(css1 css2 css3 css4) do |tag, css_class| %&gt;
    &lt;%= link_to tag.name, { :action =&gt; :tag, :id =&gt; tag.name }, :class =&gt; css_class %&gt;
  &lt;% end %&gt;
</pre>
<p>*Note. If you have a controller "tags_controller.rb" and the auto generated (if you used ./script/generate) helper file "tags_helper.rb" you'll need to make sure to copy the contents of the plugin lib module of the same name, into the helper file. You'll get an error otherwise. </p>


<p>Related posts:<ol><li><a href='http://seanbehan.com/ruby-on-rails/acts_as_versioned-rails-plugin/' rel='bookmark' title='Permanent Link: Acts_as_versioned Rails Plugin'>Acts_as_versioned Rails Plugin</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/rails-paperclip-plugin-options-for-attaching-files/' rel='bookmark' title='Permanent Link: Rails Paperclip Plugin Options for Attaching Files'>Rails Paperclip Plugin Options for Attaching Files</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/how-to-use-pretty-urls-with-rails-will_paginate-plugin/' rel='bookmark' title='Permanent Link: How to Use Pretty URLs with Rails will_paginate Plugin'>How to Use Pretty URLs with Rails will_paginate Plugin</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/rails-plugin-acts-as-taggable-on-steriods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Helper to Remove Leading Zero in 12 Hour Time Format</title>
		<link>http://seanbehan.com/ruby-on-rails/rails-helper-to-remove-leading-zero-in-12-hour-time-format/</link>
		<comments>http://seanbehan.com/ruby-on-rails/rails-helper-to-remove-leading-zero-in-12-hour-time-format/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 23:39:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[12 hour time]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[initializers]]></category>
		<category><![CDATA[leading zero]]></category>
		<category><![CDATA[strftime]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=829</guid>
		<description><![CDATA[I can&#8217;t find a strftime() format that will output the hour without the leading zero.  For instance 6:20 will be instead 06:20. This just looks a little sloppy. I created a datetime.rb intializer which will contain custom datetime formats for my application.

# RAILS_ROOT/config/initializers/datetime.rb
Time::DATE_FORMATS[:date] = "%a %b %d, %Y"
Time::DATE_FORMATS[:time] = "%I:%M%p"
# ...

Next I set up [...]


Related posts:<ol><li><a href='http://seanbehan.com/ruby/ruby-strftime-day-without-the-leading-zero/' rel='bookmark' title='Permanent Link: Ruby Strftime Day Without the Leading Zero'>Ruby Strftime Day Without the Leading Zero</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/custom-date-formats-for-your-rails-application/' rel='bookmark' title='Permanent Link: Custom Date Formats for Your Rails Application'>Custom Date Formats for Your Rails Application</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/problem-slash-bug-in-rails-with-attr_accessor-and-datetime-select-fields/' rel='bookmark' title='Permanent Link: Problem slash Bug in Rails with attr_accessor and Datetime Select Fields'>Problem slash Bug in Rails with attr_accessor and Datetime Select Fields</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I can&#8217;t find a strftime() format that will output the hour without the leading zero.  For instance 6:20 will be instead 06:20. This just looks a little sloppy. I created a datetime.rb intializer which will contain custom datetime formats for my application.</p>
<pre>
# RAILS_ROOT/config/initializers/datetime.rb
Time::DATE_FORMATS[:date] = "%a %b %d, %Y"
Time::DATE_FORMATS[:time] = "%I:%M%p"
# ...
</pre>
<p>Next I set up a helper function which will string together the :date and :time formats and remove the leading zero in the hour with the .gsub method on the string.</p>
<pre>
  # RAILS_ROOT/app/helpers/application_helper.rb
  def fulltime(created_at)
    created_at.to_s(:date)+" "+created_at.to_s(:time).gsub(/^0/,'').downcase
  end
</pre>
<p>In a view I&#8217;ll just pass the timestamp to the fulltime function</p>
<pre>
fulltime(@post.created_at)
</pre>


<p>Related posts:<ol><li><a href='http://seanbehan.com/ruby/ruby-strftime-day-without-the-leading-zero/' rel='bookmark' title='Permanent Link: Ruby Strftime Day Without the Leading Zero'>Ruby Strftime Day Without the Leading Zero</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/custom-date-formats-for-your-rails-application/' rel='bookmark' title='Permanent Link: Custom Date Formats for Your Rails Application'>Custom Date Formats for Your Rails Application</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/problem-slash-bug-in-rails-with-attr_accessor-and-datetime-select-fields/' rel='bookmark' title='Permanent Link: Problem slash Bug in Rails with attr_accessor and Datetime Select Fields'>Problem slash Bug in Rails with attr_accessor and Datetime Select Fields</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/rails-helper-to-remove-leading-zero-in-12-hour-time-format/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Extending Rails Form Builders</title>
		<link>http://seanbehan.com/ruby-on-rails/extending-rails-form-builders/</link>
		<comments>http://seanbehan.com/ruby-on-rails/extending-rails-form-builders/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 19:11:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[builders]]></category>
		<category><![CDATA[custom tag builder]]></category>
		<category><![CDATA[extending]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[label]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[text field]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=825</guid>
		<description><![CDATA[Extending forms in Rails is simple and will greatly reduce the amount of code in your views. This example is taken right from the Agile Web Development book on Rails(2.1.*) with one minor tweak. I want to pass a label argument along with the field name so that I can display a more human friendly [...]


Related posts:<ol><li><a href='http://seanbehan.com/ruby-on-rails/nested-attributes-in-a-form-for-has_one-model-association-in-rails/' rel='bookmark' title='Permanent Link: Nested Attributes in a Form for Has_One Model Association in Rails'>Nested Attributes in a Form for Has_One Model Association in Rails</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/onchange-event-fired-from-select-field-in-rails-form/' rel='bookmark' title='Permanent Link: Onchange Event Fired from Select Field in Rails Form'>Onchange Event Fired from Select Field in Rails Form</a></li>
<li><a href='http://seanbehan.com/programming/using-prototype-to-access-form-data/' rel='bookmark' title='Permanent Link: Using Prototype to Access Form Data'>Using Prototype to Access Form Data</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Extending forms in Rails is simple and will greatly reduce the amount of code in your views. This example is taken right from the Agile Web Development book on Rails(2.1.*) with one minor tweak. I want to pass a label argument along with the field name so that I can display a more human friendly string to represent the form field. </p>
<pre>
# RAILS_ROOT/app/helpers/custom_tag_builder.rb
class CustomTagBuilder < ActionView::Helpers::FormBuilder

  def self.create_tagged_field(method_name)
    define_method(method_name) do |label, *args|
      label_name = args.first.blank? ? label : args.first[:label] # my change
      @template.content_tag("p",
        @template.content_tag("label",
          label_name.to_s.humanize, :for => "#{@object_name}_#{label}") +" <br/> "+ super)
    end
  end  

  field_helpers.each do |name|
    create_tagged_field(name)
  end
end
</pre>
<p>You can then use this in your views </p>
<pre>
form_for @your_model, :builder => CustomTagBuilder do |f|
  f.text_field :fullname
  f.text_field :email, :label => "Email (will not be published)"
</pre>
<p>My change tests for the presence of a label argument otherwise using the name of the form field/model attribute. In this case the fullname attribute will be outputted as &#8220;Fullname&#8221; while &#8220;Email (will not be published)&#8221; as the label for the email text field.   </p>


<p>Related posts:<ol><li><a href='http://seanbehan.com/ruby-on-rails/nested-attributes-in-a-form-for-has_one-model-association-in-rails/' rel='bookmark' title='Permanent Link: Nested Attributes in a Form for Has_One Model Association in Rails'>Nested Attributes in a Form for Has_One Model Association in Rails</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/onchange-event-fired-from-select-field-in-rails-form/' rel='bookmark' title='Permanent Link: Onchange Event Fired from Select Field in Rails Form'>Onchange Event Fired from Select Field in Rails Form</a></li>
<li><a href='http://seanbehan.com/programming/using-prototype-to-access-form-data/' rel='bookmark' title='Permanent Link: Using Prototype to Access Form Data'>Using Prototype to Access Form Data</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/extending-rails-form-builders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install and Serve a Rails Application from PHP Subdirectory Using Apache, Phussion Passenger and Ruby Enterprise Edition</title>
		<link>http://seanbehan.com/ruby-on-rails/install-and-serve-a-rails-application-from-php-subdirectory-using-apache-phussion-passenger-and-ruby-enterprise-edition/</link>
		<comments>http://seanbehan.com/ruby-on-rails/install-and-serve-a-rails-application-from-php-subdirectory-using-apache-phussion-passenger-and-ruby-enterprise-edition/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 21:40:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[alias]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[feedzirra]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[mod rails]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[passenger app root]]></category>
		<category><![CDATA[path prefix]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phussion]]></category>
		<category><![CDATA[ree]]></category>
		<category><![CDATA[relative url rails]]></category>
		<category><![CDATA[routing]]></category>
		<category><![CDATA[ruby enterprise edition]]></category>
		<category><![CDATA[subdirectory]]></category>
		<category><![CDATA[VirtualHost]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=795</guid>
		<description><![CDATA[Here is how to install a Rails application out of a subdirectory (rather than as a subdomain) with the Apache web server(Apache2). In this example I&#8217;m going to use my own blog which is a Wordpress installation and serve a Rails application from the subdirectory &#8220;reader&#8221;. Note, I&#8217;m not going to keep my Rails application [...]


Related posts:<ol><li><a href='http://seanbehan.com/ruby-on-rails/how-to-install-ferret-the-full-text-search-engine-with-your-rails-application/' rel='bookmark' title='Permanent Link: How to Install Ferret, the Full Text Search Engine with Your Rails Application'>How to Install Ferret, the Full Text Search Engine with Your Rails Application</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/new-ubuntu-slice-apache-mysql-php-ruby-on-rails-git-and/' rel='bookmark' title='Permanent Link: Setting up a new ubuntu server with apache2, php, ruby on rails, rubygems, mysql, and git'>Setting up a new ubuntu server with apache2, php, ruby on rails, rubygems, mysql, and git</a></li>
<li><a href='http://seanbehan.com/sinatra/deploy-sintra-app-on-ubuntu-using-apache2-and-phusion-passenger-module/' rel='bookmark' title='Permanent Link: Deploy Sintra App on Ubuntu Using Apache2 and Phusion Passenger Module'>Deploy Sintra App on Ubuntu Using Apache2 and Phusion Passenger Module</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Here is how to install a Rails application out of a subdirectory (rather than as a subdomain) with the Apache web server(Apache2). In this example I&#8217;m going to use my own blog which is a Wordpress installation and serve a Rails application from the subdirectory &#8220;reader&#8221;. Note, I&#8217;m not going to keep my Rails application in the document root of my Wordpress Blog, which is a PHP application and therefore anyone could browse the ruby source code <img src='http://seanbehan.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> . I&#8217;ll keep it elsewhere on the filesystem and tell Apache about the location in the VirtualHost file. </p>
<p>You can visit the application by going to  <a href="http://seanbehan.com/reader">http://seanbehan.com/reader</a>. The application just parses a bunch of RSS feeds and displays them.<br />
It uses the Feedzirra library, which I&#8217;ve also written about <a href="http://seanbehan.com/ruby-on-rails/installing-feedzirra-rss-parser-on-ubuntu-8/">http://seanbehan.com/ruby-on-rails/installing-feedzirra-rss-parser-on-ubuntu-8/</a>.</p>
<p>I&#8217;m using Phussion Passenger and Ruby Enterprise Edition from the folks at <a href="http://www.modrails.com/">Mod Rails</a>. Installing both Phussion Passenger and Ruby Enterprise Edition is simple and a very well documented process. However, you&#8217;ll need to download and compile them from source. If you install Ruby Enterprise Edition (REE) it comes w/ Passenger so you won&#8217;t need to download it separately. I recommend going with REE. <a href="http://www.rubyenterpriseedition.com/download.html">http://www.rubyenterpriseedition.com/download.html</a></p>
<h3>Installing Ruby Enterprise Edition</h3>
<p>Here are the commands to download and install (change the X.X.X to the package you&#8217;ve actually downloaded). </p>
<pre>
wget http://rubyforge.org/frs/download.php/68719/ruby-enterprise-1.8.7-2010.01.tar.gz
tar xzvf ruby-enterprise-X.X.X.tar.gz
./ruby-enterprise-X.X.X/installer
</pre>
<p>When you run the installer you&#8217;ll be prompted for an installation location. Just hit enter to install in the default location. Follow the instructions from there and remember to copy/paste any code that they give you. </p>
<p>Official Instructions on installation for Passenger on its own are available here <a href="http://www.modrails.com/install.html">http://www.modrails.com/install.html</a> I&#8217;ve written about setting up an entire box w/ Passenger here <a href="http://seanbehan.com/ruby-on-rails/new-ubuntu-slice-apache-mysql-php-ruby-on-rails-git-and/">http://seanbehan.com/ruby-on-rails/new-ubuntu-slice-apache-mysql-php-ruby-on-rails-git-and/</a> If you already have Passenger installed and want to use REE just download and install REE and it&#8217;ll recompile Passenger with REE support if you follow the instructions. </p>
<p>*** If you install REE you&#8217;ll need to either link or reinstall all your gems. I linked the REE gem with the one in /usr/bin so that I can run  gem install <gem name> and REE will be aware of it. </p>
<pre>
ln -s /opt/ruby-enterprise-X.X.X/bin/gem /usr/bin/gem
</pre>
<h3>The VirtualHost</h3>
<p>If you have Passenger and REE successfully installed you&#8217;ll need to modify your VirtualHost file and add Rails application information to it. </p>
<pre>
&lt;VirtualHost *&gt;
  # Normal virtual host info
  ServerName seanbehan.com
  ServerAlias *.seanbehan.com
  DocumentRoot /var/www/seanbehan.com/wordpress

  # Rails info goes here
  Alias /reader /var/www/seanbehan.com/reader/public
  &lt;Location /reader&gt;
    PassengerAppRoot /var/www/seanbehan.com/reader
    RailsEnv production
  &lt;/Location&gt;
&lt;/VirtualHost&gt;
</pre>
<p>The &#8220;Location&#8221; directive tells apache to forward requests starting with /reader to the directory<br />
/var/www/seanbehan.com/reader/public which is the location of our Rails app. However, we need to add the PassengerAppRoot assignment so that it knows where the actual application lives. </p>
<h3>Routing in Rails with Relative Path</h3>
<p>And finally, your Rails application will need to be aware of the relative url prefix assigned to each route. Normally, you could do this w/ the :path_prefix at the individual route level like so </p>
<pre>
map.resources :feeds, :path_prefix => "reader"
</pre>
<p>This will work but you can add a line to your RAILS_ROOT/config/environments/production.rb file which will handle all your routes for you. This way you don&#8217;t need to setup a relative path on your development environment work. </p>
<pre>
# in RAILS_ROOT/config/environments/production.rb
config.action_controller.relative_url_root = '/reader'
</pre>
<h3>Final Thoughts</h3>
<p>Remember Ruby Enterprise Edition is the new Ruby Interpreter that your Rails web applications are using. If you<br />
have any gem or rake issues make sure that you&#8217;re using the same interpreter that REE is using. Look in the location<br />
installation of REE &#8220;/opt/ruby-ent&#8230;&#8221; bin/gem or bin/rake and see if that helps. I just linked those to the standard /usr/bin/gem and /usr/bin/rake and everything worked fine. </p>
<p>Also I&#8217;ve read some people have trouble using the alias with passenger. This may be an older issue but works for me without a problem on Ubuntu (latest).  </p>
<p>Here are some useful resources I found along the way&#8230;</p>
<p>http://robots.thoughtbot.com/post/159806388/phusion-passenger-with-a-prefix</p>
<p>http://www.modrails.com/documentation/Users%20guide.html#deploying_rails_to_sub_uri</p>
<p>http://www.modrails.com/documentation/Users%20guide.html#RailsBaseURI</p>
<p>http://stackoverflow.com/questions/848258/server-prefix-and-rails-routes</p>


<p>Related posts:<ol><li><a href='http://seanbehan.com/ruby-on-rails/how-to-install-ferret-the-full-text-search-engine-with-your-rails-application/' rel='bookmark' title='Permanent Link: How to Install Ferret, the Full Text Search Engine with Your Rails Application'>How to Install Ferret, the Full Text Search Engine with Your Rails Application</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/new-ubuntu-slice-apache-mysql-php-ruby-on-rails-git-and/' rel='bookmark' title='Permanent Link: Setting up a new ubuntu server with apache2, php, ruby on rails, rubygems, mysql, and git'>Setting up a new ubuntu server with apache2, php, ruby on rails, rubygems, mysql, and git</a></li>
<li><a href='http://seanbehan.com/sinatra/deploy-sintra-app-on-ubuntu-using-apache2-and-phusion-passenger-module/' rel='bookmark' title='Permanent Link: Deploy Sintra App on Ubuntu Using Apache2 and Phusion Passenger Module'>Deploy Sintra App on Ubuntu Using Apache2 and Phusion Passenger Module</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby-on-rails/install-and-serve-a-rails-application-from-php-subdirectory-using-apache-phussion-passenger-and-ruby-enterprise-edition/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Strftime Day Without the Leading Zero</title>
		<link>http://seanbehan.com/ruby/ruby-strftime-day-without-the-leading-zero/</link>
		<comments>http://seanbehan.com/ruby/ruby-strftime-day-without-the-leading-zero/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 00:08:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[%e]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[strftime]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=798</guid>
		<description><![CDATA[
%e # rather than %d
Time.now.strftime("%e")



Related posts:Ruby strftime() method arguments
Rails Helper to Remove Leading Zero in 12 Hour Time Format



Related posts:<ol><li><a href='http://seanbehan.com/programming/ruby-strftime-method-arguments/' rel='bookmark' title='Permanent Link: Ruby strftime() method arguments'>Ruby strftime() method arguments</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/rails-helper-to-remove-leading-zero-in-12-hour-time-format/' rel='bookmark' title='Permanent Link: Rails Helper to Remove Leading Zero in 12 Hour Time Format'>Rails Helper to Remove Leading Zero in 12 Hour Time Format</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<pre>
%e # rather than %d
Time.now.strftime("%e")
</pre>


<p>Related posts:<ol><li><a href='http://seanbehan.com/programming/ruby-strftime-method-arguments/' rel='bookmark' title='Permanent Link: Ruby strftime() method arguments'>Ruby strftime() method arguments</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/rails-helper-to-remove-leading-zero-in-12-hour-time-format/' rel='bookmark' title='Permanent Link: Rails Helper to Remove Leading Zero in 12 Hour Time Format'>Rails Helper to Remove Leading Zero in 12 Hour Time Format</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/ruby/ruby-strftime-day-without-the-leading-zero/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the PHP Mail Function with Additional Headers</title>
		<link>http://seanbehan.com/php/using-the-php-mail-function-with-additional-headers/</link>
		<comments>http://seanbehan.com/php/using-the-php-mail-function-with-additional-headers/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 19:12:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[headers]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=791</guid>
		<description><![CDATA[Pass a fourth parameter to the mail() function with the header information.

&#60;?php
$to = "jane@example.com";
$subject = "Hello World!";
$body = "This will be sent from email-addr@example.com";
$headers = "From: email-addr@example.com\r\nX-Mailer: php";
mail($to, $subject, $body, $headers);



Related posts:Send Mail in Ruby with a Pony
Updating Your Twitter Status with cURL and a Bash Function
Using sendmail to send mail on ubuntu box



Related posts:<ol><li><a href='http://seanbehan.com/programming/send-mail-in-ruby-with-a-pony/' rel='bookmark' title='Permanent Link: Send Mail in Ruby with a Pony'>Send Mail in Ruby with a Pony</a></li>
<li><a href='http://seanbehan.com/linux/updating-your-twitter-status-with-curl-and-a-bash-function/' rel='bookmark' title='Permanent Link: Updating Your Twitter Status with cURL and a Bash Function'>Updating Your Twitter Status with cURL and a Bash Function</a></li>
<li><a href='http://seanbehan.com/linux/using-sendmail-to-send-mail-on-ubuntu-box/' rel='bookmark' title='Permanent Link: Using sendmail to send mail on ubuntu box'>Using sendmail to send mail on ubuntu box</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Pass a fourth parameter to the mail() function with the header information.</p>
<pre>
&lt;?php
$to = "jane@example.com";
$subject = "Hello World!";
$body = "This will be sent from email-addr@example.com";
$headers = "From: email-addr@example.com\r\nX-Mailer: php";
mail($to, $subject, $body, $headers);
</pre>


<p>Related posts:<ol><li><a href='http://seanbehan.com/programming/send-mail-in-ruby-with-a-pony/' rel='bookmark' title='Permanent Link: Send Mail in Ruby with a Pony'>Send Mail in Ruby with a Pony</a></li>
<li><a href='http://seanbehan.com/linux/updating-your-twitter-status-with-curl-and-a-bash-function/' rel='bookmark' title='Permanent Link: Updating Your Twitter Status with cURL and a Bash Function'>Updating Your Twitter Status with cURL and a Bash Function</a></li>
<li><a href='http://seanbehan.com/linux/using-sendmail-to-send-mail-on-ubuntu-box/' rel='bookmark' title='Permanent Link: Using sendmail to send mail on ubuntu box'>Using sendmail to send mail on ubuntu box</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/using-the-php-mail-function-with-additional-headers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dump MySQL Database without Drop Table Syntax</title>
		<link>http://seanbehan.com/databases/dump-mysql-database-without-drop-table-syntax/</link>
		<comments>http://seanbehan.com/databases/dump-mysql-database-without-drop-table-syntax/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 00:57:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[flags]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[syntax]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=781</guid>
		<description><![CDATA[Output .sql file for MySQL but without the drop table syntax before table name use the &#8211;skip-add-drop-table flag

mysqldump -u root -p database_name --skip-add-drop-table --skip-lock-tables > database_name.sql



Related posts:Sample Rails Database Config  for MySQL
Quick Syntax to Pipe an SQL Query Directly to a file
Managing Timestamps in MySQL with a Trigger



Related posts:<ol><li><a href='http://seanbehan.com/ruby-on-rails/sample-rails-database-config-for-mysql/' rel='bookmark' title='Permanent Link: Sample Rails Database Config  for MySQL'>Sample Rails Database Config  for MySQL</a></li>
<li><a href='http://seanbehan.com/programming/quick-syntax-to-pipe-an-sql-query-directly-to-a-file/' rel='bookmark' title='Permanent Link: Quick Syntax to Pipe an SQL Query Directly to a file'>Quick Syntax to Pipe an SQL Query Directly to a file</a></li>
<li><a href='http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/' rel='bookmark' title='Permanent Link: Managing Timestamps in MySQL with a Trigger'>Managing Timestamps in MySQL with a Trigger</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Output .sql file for MySQL but without the drop table syntax before table name use the &#8211;skip-add-drop-table flag</p>
<pre>
mysqldump -u root -p database_name --skip-add-drop-table --skip-lock-tables > database_name.sql
</pre>


<p>Related posts:<ol><li><a href='http://seanbehan.com/ruby-on-rails/sample-rails-database-config-for-mysql/' rel='bookmark' title='Permanent Link: Sample Rails Database Config  for MySQL'>Sample Rails Database Config  for MySQL</a></li>
<li><a href='http://seanbehan.com/programming/quick-syntax-to-pipe-an-sql-query-directly-to-a-file/' rel='bookmark' title='Permanent Link: Quick Syntax to Pipe an SQL Query Directly to a file'>Quick Syntax to Pipe an SQL Query Directly to a file</a></li>
<li><a href='http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/' rel='bookmark' title='Permanent Link: Managing Timestamps in MySQL with a Trigger'>Managing Timestamps in MySQL with a Trigger</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/databases/dump-mysql-database-without-drop-table-syntax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate MySQL Datetime Type Using PHP Date() Function</title>
		<link>http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/</link>
		<comments>http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/#comments</comments>
		<pubDate>Fri, 05 Feb 2010 18:22:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[php]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[strftime]]></category>
		<category><![CDATA[type]]></category>

		<guid isPermaLink="false">http://seanbehan.com/?p=779</guid>
		<description><![CDATA[If you want to insert a datetime that matches the default mysql datetime type format use this 

date('Y-m-d H:i:s');



Related posts:Managing Timestamps in MySQL with a Trigger
Problem slash Bug in Rails with attr_accessor and Datetime Select Fields
Custom Date Formats for Your Rails Application



Related posts:<ol><li><a href='http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/' rel='bookmark' title='Permanent Link: Managing Timestamps in MySQL with a Trigger'>Managing Timestamps in MySQL with a Trigger</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/problem-slash-bug-in-rails-with-attr_accessor-and-datetime-select-fields/' rel='bookmark' title='Permanent Link: Problem slash Bug in Rails with attr_accessor and Datetime Select Fields'>Problem slash Bug in Rails with attr_accessor and Datetime Select Fields</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/custom-date-formats-for-your-rails-application/' rel='bookmark' title='Permanent Link: Custom Date Formats for Your Rails Application'>Custom Date Formats for Your Rails Application</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>If you want to insert a datetime that matches the default mysql datetime type format use this </p>
<pre>
date('Y-m-d H:i:s');
</pre>


<p>Related posts:<ol><li><a href='http://seanbehan.com/databases/managing-timestamps-in-mysql-with-a-trigger/' rel='bookmark' title='Permanent Link: Managing Timestamps in MySQL with a Trigger'>Managing Timestamps in MySQL with a Trigger</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/problem-slash-bug-in-rails-with-attr_accessor-and-datetime-select-fields/' rel='bookmark' title='Permanent Link: Problem slash Bug in Rails with attr_accessor and Datetime Select Fields'>Problem slash Bug in Rails with attr_accessor and Datetime Select Fields</a></li>
<li><a href='http://seanbehan.com/ruby-on-rails/custom-date-formats-for-your-rails-application/' rel='bookmark' title='Permanent Link: Custom Date Formats for Your Rails Application'>Custom Date Formats for Your Rails Application</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://seanbehan.com/php/generate-mysql-datetime-type-using-php-date-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
