<?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>Innovative Thought &#187; Programming</title>
	<atom:link href="http://innovativethought.net/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://innovativethought.net</link>
	<description>think. code. design. innovate.</description>
	<lastBuildDate>Mon, 05 Mar 2012 20:06:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='innovativethought.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Innovative Thought &#187; Programming</title>
		<link>http://innovativethought.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://innovativethought.net/osd.xml" title="Innovative Thought" />
	<atom:link rel='hub' href='http://innovativethought.net/?pushpress=hub'/>
		<item>
		<title>Fun with the simple_form Rails Gem</title>
		<link>http://innovativethought.net/2011/02/23/fun-with-the-simple_form-rails-gem/</link>
		<comments>http://innovativethought.net/2011/02/23/fun-with-the-simple_form-rails-gem/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 03:49:06 +0000</pubDate>
		<dc:creator>Tim Knight</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[simple_form]]></category>

		<guid isPermaLink="false">https://innovativethought.wordpress.com/?p=283</guid>
		<description><![CDATA[It&#8217;s been a long time since I sat down to write a blog about a programming related topic. I&#8217;m really hoping that changes this year, but I&#8217;ll do my best not to make promises I can&#8217;t be sure I&#8217;ll keep. I definitely hope to share more of the things I&#8217;m learning about and playing with. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=283&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a long time since I sat down to write a blog about a programming related topic. I&#8217;m really hoping that changes this year, but I&#8217;ll do my best not to make promises I can&#8217;t be sure I&#8217;ll keep. I definitely hope to share more of the things I&#8217;m learning about and playing with. With that in mind, I was playing with the <a href="https://github.com/plataformatec/simple_form">simple_form</a> gem earlier today and I thought I would share the experiment that I was working on.</p>
<p>Often when working on a project I&#8217;ll have a few basic forms that I need for data entry within the system. Nothing too complex, just a few simple fields. For those of you who haven&#8217;t checked out simple_form yet, I highly recommend it. After getting the gem installed I created the form I needed:</p>
<p><code>
<pre>&lt;%= simple_form_for @member do |f| %&gt;
  &lt;%= f.input :firstname %&gt;
  &lt;%= f.input :lastname %&gt;
  &lt;%= f.input :email %&gt;
  &lt;%= f.input :bio %&gt;
  &lt;%= f.button :submit %&gt;
&lt;% end %&gt;</pre>
<p></code></p>
<p>Knowing that I would need a few more simple forms I wanted to figure out a way to be able to reuse this code snippet. Although I might not do this same approach in a large project with more complex forms I proceeded to pull out the column symbols within the snippet and came up with this:</p>
<p><code>
<pre>&lt;%= simple_form_for @member do |f| %&gt;
  &lt;% @member.class.column_names.each do |field| %&gt;
    &lt;%= f.input field.to_sym unless %w{id created_at updated_at}.include?(field) %&gt;
  &lt;% end %&gt;
  &lt;%= f.submit %&gt;
&lt;% end %&gt;</pre>
<p></code></p>
<p>This takes the @member instance variable and get its class, which in this case is Member. It looks at the column names of Member and loops through them. If the field isn&#8217;t &#8220;id&#8221;, &#8220;created_at&#8221;, or &#8220;updated_at&#8221; it creates an input field for it. This was a step closer to what I was going for. I imagine there are many opinions about this approach especially when it comes to thoughts on performance. The focus here was about experimentation. So I keep going and made some additional adjustments, caming up with this:</p>
<p><code>
<pre>&lt;%= simple_form_for form do |f| %&gt;
  &lt;% form.class.column_names.each do |field| %&gt;
    &lt;%= f.input field.to_sym unless %w{id created_at updated_at}.include?(field) %&gt;
  &lt;% end %&gt;
  &lt;%= f.submit %&gt;
&lt;% end %&gt;</pre>
<p></code></p>
<p>This allowed me to call the code as a partial like:</p>
<p><code>
<pre>&lt;%= render :partial =&gt; &#x27;shared/form&#x27;, :object =&gt; @member %&gt;</pre>
<p></code></p>
<p>It&#8217;s not perfect, I can&#8217;t customize the fields in any way, but it let&#8217;s me get some basic forms quickly together for testing concepts with a customer.</p>
<p>Anyway, that&#8217;s my recent experiment, feel free to share your thoughts and feedback.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/innovativethought.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/innovativethought.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/innovativethought.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/innovativethought.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/innovativethought.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/innovativethought.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/innovativethought.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/innovativethought.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/innovativethought.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/innovativethought.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/innovativethought.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/innovativethought.wordpress.com/283/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/innovativethought.wordpress.com/283/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/innovativethought.wordpress.com/283/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=283&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://innovativethought.net/2011/02/23/fun-with-the-simple_form-rails-gem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2722012beb9afcad75df5c9f2229fd8c?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Tim Knight</media:title>
		</media:content>
	</item>
		<item>
		<title>Magic-Ruby 2011 Conference Talks</title>
		<link>http://innovativethought.net/2011/02/06/magic-ruby-2011-conference-talks/</link>
		<comments>http://innovativethought.net/2011/02/06/magic-ruby-2011-conference-talks/#comments</comments>
		<pubDate>Sun, 06 Feb 2011 20:27:58 +0000</pubDate>
		<dc:creator>Tim Knight</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[magic-ruby]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">https://innovativethought.wordpress.com/?p=248</guid>
		<description><![CDATA[I was lucky enough to be able to spend the last few days with some amazing Ruby developers. I enjoyed meeting so many new people and getting the chance to learn about some seriously awesome projects that they are working on. In an effort to consolidate some of the slides and information shared by the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=248&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was lucky enough to be able to spend the last few days with some amazing Ruby developers. I enjoyed meeting so many new people and getting the chance to learn about some seriously awesome projects that they are working on. In an effort to consolidate some of the slides and information shared by the speakers I&#8217;ve created this post. If you have any updates please leave them in the comments and I&#8217;ll continue to complete the list.</p>
<h2>Friday</h2>
<ul>
<li>Cultivating Cucumber: <a href="http://www.slideshare.net/leshill/cultivating-cucumber">Slides</a><br /><em>Les Hill, Hashrocket</em></li>
<li>Geospacing Your Ruby: <a href="http://blog.peteonrails.com/?p=253">Slides and Video of similar talk from July 9, 2010</a><br /><em>Peter Jackson, Intridea</em></li>
<li>Loving your customers, loving your peers<br /><em>Alan Johnson, Carsonified</em></li>
<li>Code Isn&#8217;t Enough<br /><em>Gregg Pollack / Caike Souza</em></li>
<li>Exceptional Ruby: <a href="http://avdi.org/devblog/2011/02/05/thank-you-magic-ruby/">Slides, Code, and Review</a> | <a href="http://avdi.org/devblog/2011/02/14/exceptional-ruby-video-and-beta-ebook/">Video</a><br /><em>Avdi Grimm</em></li>
<li>What Happened to Desktop Development in Ruby<br /><em>Andy Maleh, Obtiva</em></li>
<li>Keynote<br /><em>Dave Thomas, Pragmatic Programmers</em></li>
</ul>
<h2>Saturday</h2>
<ul>
<li>Meditation + Code: <a href="http://www.slideshare.net/msgehard/meditation-and-software">Slides</a><br /><em>Mike Gehard, Pivotal Labs</em></li>
<li>Crank Up Your Apps with TorqueBox: <a href="http://www.slideshare.net/jcrossley3/crank-up-your-apps-with-torquebox">Slides</a> | <a href="http://torquebox.org/news/2011/02/08/magic-ruby-preso/">Video</a><br /><em>Jim Crossley, Red Hat</em></li>
<li>How I Learned to Stop Worrying and Love the Cloud: <a href="http://www.slideshare.net/geemus/fog-or-how-i-learned-to-stop-worrying-and-love-the-cloud">Slides</a><br /><em>Wesley Beary, Engine Yard</em></li>
<li>Developing Cocoa Applications with MacRuby: <a href="http://www.slideshare.net/brendanlim/developing-cocoa-applications-with-macruby">Slides</a><br /><em>Brendan Lim, Intridea</em></li>
<li>Documentation is freaking awesome: <a href="http://warpspire.com/talks/documentation/">Slides and Links</a><br /><em>Kyle Neath, Github</em></li>
<li>Lightning Talks: <a href="http://viddler.com/magicruby">Videos</a></li>
<li>Keynote &#8211; McDonalds, Six Sigma, and Offshore Outsourcing: <a href="http://www.chadfowler.com/2011/2/10/mcdonalds-six-sigma-and-offshore-outsourcing-notes">Notes</a><br /><em>Chad Fowler, InfoEther</em></li>
</ul>
<p>A special thanks to all the speakers and <a href="http://www.jeremymcanally.com/">Jeremy McAnally</a> for putting it all together. Anyone wishing to stay in touch can find me on Twitter <a href="http://twitter.com/#!/timknight/">@timknight</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/innovativethought.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/innovativethought.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/innovativethought.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/innovativethought.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/innovativethought.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/innovativethought.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/innovativethought.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/innovativethought.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/innovativethought.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/innovativethought.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/innovativethought.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/innovativethought.wordpress.com/248/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/innovativethought.wordpress.com/248/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/innovativethought.wordpress.com/248/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=248&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://innovativethought.net/2011/02/06/magic-ruby-2011-conference-talks/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2722012beb9afcad75df5c9f2229fd8c?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Tim Knight</media:title>
		</media:content>
	</item>
		<item>
		<title>Making Configuration Files with YAML: Revised</title>
		<link>http://innovativethought.net/2009/01/02/making-configuration-files-with-yaml-revised/</link>
		<comments>http://innovativethought.net/2009/01/02/making-configuration-files-with-yaml-revised/#comments</comments>
		<pubDate>Sat, 03 Jan 2009 02:27:08 +0000</pubDate>
		<dc:creator>Tim Knight</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[YAML]]></category>

		<guid isPermaLink="false">http://innovativethought.wordpress.com/2009/01/03/making-configuration-files-with-yaml-revised/</guid>
		<description><![CDATA[So back in July 2007 I posted a blog on making configuration files with YAML, and I&#8217;ve been noticing a lot of readership on the old article. Because it seems that a lot of people are reading it I felt it was important to show how I apply this nowadays. First I put my config.yml [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=105&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So back in July 2007 I posted a blog <a href="http://blog.innovativethought.net/2007/07/25/making-configuration-files-with-yaml/">on making configuration files with YAML</a>, and I&#8217;ve been noticing a lot of readership on the old article. Because it seems that a lot of people are reading it I felt it was important to show how I apply this nowadays.</p>
<p>First I put my <kbd>config.yml</kbd> file within the <kbd>/config/</kbd> directory within my Rails application. It looks something like this:</p>
<pre><code>development: &amp;non_production_settings
  :google_analytics:
    :api_key: "[Enter Google ID]"
  :site:
    :title: "[Title]"
    :address: "http://localhost:3000/"

test:
  &lt;&lt;: *non_production_settings

production:
  :google_analytics:
    :api_key: "[Enter Google ID]"
  :site:
    :title: "[Title]"
    :address: "[Address]"</code></pre>
<p>Then, I create a new file called <kbd>load_config.rb</kbd> within the <kbd>/config/initializers</kbd> directory. You can name the file whatever you want &#8211; that&#8217;s just what I call it. This is where the actually YAML loading is going to happen &#8211; and this is what it looks like:</p>
<pre><code>raw_config = File.read(RAILS_ROOT + "/config/config.yml")
APP_CONFIG = YAML.load(raw_config)[RAILS_ENV]</code></pre>
<p>Now any time I want to all one of these variables I just call it like:</p>
<pre><code>&lt;%= APP_CONFIG[:site][:title] %&gt;</code></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/innovativethought.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/innovativethought.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/innovativethought.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/innovativethought.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/innovativethought.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/innovativethought.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/innovativethought.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/innovativethought.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/innovativethought.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/innovativethought.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/innovativethought.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/innovativethought.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/innovativethought.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/innovativethought.wordpress.com/105/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=105&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://innovativethought.net/2009/01/02/making-configuration-files-with-yaml-revised/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2722012beb9afcad75df5c9f2229fd8c?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Tim Knight</media:title>
		</media:content>
	</item>
		<item>
		<title>Optimizing the RedCloth Helper</title>
		<link>http://innovativethought.net/2008/12/01/optimizing-the-redcloth-helper/</link>
		<comments>http://innovativethought.net/2008/12/01/optimizing-the-redcloth-helper/#comments</comments>
		<pubDate>Mon, 01 Dec 2008 08:44:37 +0000</pubDate>
		<dc:creator>Tim Knight</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://innovativethought.wordpress.com/?p=91</guid>
		<description><![CDATA[In my previous post I posted several small Rails tips, one of which was a cleaner RedCloth helper. Unfortunately, this helper requires that the textile is parsed each time the page is loaded, and that can get nasty. So it our item is a text field called details, just add a details_html field to your [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=91&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my previous post I posted several small Rails tips, one of which was a cleaner RedCloth helper. Unfortunately, this helper requires that the textile is parsed each time the page is loaded, and that can get nasty. So it our item is a text field called details, just add a details_html field to your model&#8230; then create a private conversion method that you call using a before_filter.</p>
<p>Something like:</p>
<pre>before_filter :convert_details

def convert_details
  return if self.details.nil?
  self.details_html = RedCloth.new(self.details).to_html
end </pre>
<p>Then just display details_html in your view instead. This way the textile only gets converted when you save and make changes to it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/innovativethought.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/innovativethought.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/innovativethought.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/innovativethought.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/innovativethought.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/innovativethought.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/innovativethought.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/innovativethought.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/innovativethought.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/innovativethought.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/innovativethought.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/innovativethought.wordpress.com/91/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/innovativethought.wordpress.com/91/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/innovativethought.wordpress.com/91/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=91&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://innovativethought.net/2008/12/01/optimizing-the-redcloth-helper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2722012beb9afcad75df5c9f2229fd8c?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Tim Knight</media:title>
		</media:content>
	</item>
		<item>
		<title>Rails Tip Roundup</title>
		<link>http://innovativethought.net/2008/10/11/rails-tip-roundup/</link>
		<comments>http://innovativethought.net/2008/10/11/rails-tip-roundup/#comments</comments>
		<pubDate>Sat, 11 Oct 2008 05:50:47 +0000</pubDate>
		<dc:creator>Tim Knight</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://innovativethought.wordpress.com/?p=85</guid>
		<description><![CDATA[I&#8217;ve been working on a few new projects lately and wanted to share a few little tips I&#8217;ve started doing. Conditional Buttons for Shared Forms Something that I like to do is use a shared form for both my edit and new views. Doing this however means I need to be friendly to the user [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=85&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a few new projects lately and wanted to share a few little tips I&#8217;ve started doing.</p>
<h2>Conditional Buttons for Shared Forms</h2>
<p>Something that I like to do is use a shared form for both my edit and new views. Doing this however means I need to be friendly to the user interface and make sure the submit button is properly instructional. So for example if I have a Customer model with an instance variable @customer my button would look like this:</p>
<pre>&lt;%= f.submit((@customer.new_record? ? "Create" : "Update") + " Customer") %&gt;</pre>
<p>With this I&#8217;m checking to see if the @customer instance variable belongs to a new record and if so it&#8217;s outputs Create, otherwise it&#8217;s an Update button.</p>
<h2>Cleaner RedCloth Helper</h2>
<p>There is the built-in textile helper that comes with Rails, it&#8217;s carage return rendering is a bit lame so most people typically upgrade their RedCloth gem and using something like:</p>
<pre>&lt;%= RedCloth.new("My copy that requires formatting").to_html =&gt;</pre>
<p>I prefer to instead create an application level helper for redcloth (some people might instead overwrite the textile helper here, but I find that can be confusing to some people looking at your code for the first time). My helper looks like this:</p>
<pre>def redcloth(str)
   RedCloth.new(str).to_html
end</pre>
<p>So now when I want to redcloth something I just call:</p>
<pre>&lt;%= redcloth("My copy that requires formatting") %&gt;</pre>
<h2>Simple Little Permalink</h2>
<p>When I have a simple object that I want to create more user-friendly URLs for, I&#8217;ll create a basic permalink. In the instance of the same Customer model from tip 1 above, I like to use the customer name as the permalink. To do this of course the name has to be unique so make sure you are validating it&#8217;s uniquiness above all. Then I create a permalink column in the database table and write something like this in my model.</p>
<pre>def name=(value)
  write_attribute :name, value
  write_attribute :permalink, value.gsub(/\s/, "-").gsub(/[^\w-]/, '').downcase
end

def to_param
  permalink
end</pre>
<p>This uses the value of the name that is entered, clears it of puncuation, replaces spaces with hyphens and drops the casing. The first line makes sure it still remembers it needs to write the value itself to the name column in the model.</p>
<p>Now it&#8217;s still important that you confirm that the permalink is unique too, but I&#8217;ll let you do that on your own.</p>
<p>So that&#8217;s it &#8211; I hope you guys find it useful.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/innovativethought.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/innovativethought.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/innovativethought.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/innovativethought.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/innovativethought.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/innovativethought.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/innovativethought.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/innovativethought.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/innovativethought.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/innovativethought.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/innovativethought.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/innovativethought.wordpress.com/85/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/innovativethought.wordpress.com/85/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/innovativethought.wordpress.com/85/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=85&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://innovativethought.net/2008/10/11/rails-tip-roundup/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2722012beb9afcad75df5c9f2229fd8c?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Tim Knight</media:title>
		</media:content>
	</item>
		<item>
		<title>Rolling with Rails 2.0RC1</title>
		<link>http://innovativethought.net/2007/11/28/rolling-with-rails-20rc1/</link>
		<comments>http://innovativethought.net/2007/11/28/rolling-with-rails-20rc1/#comments</comments>
		<pubDate>Thu, 29 Nov 2007 04:38:35 +0000</pubDate>
		<dc:creator>Tim Knight</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://innovativethought.wordpress.com/2007/11/28/rolling-with-rails-20rc1/</guid>
		<description><![CDATA[I&#8217;ve never been a fan of using rake to download EdgeRails. To me it never seemed to make sense that you would make a Rails project generated by one version and then download the Edge version into the plugins directory. So with that in mind I&#8217;m going to tell you how I roll out EdgeRails [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=48&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve never been a fan of using rake to download EdgeRails.  To me it never seemed to make sense that you would make a Rails project generated by one version and then download the Edge version into the plugins directory.  So with that in mind I&#8217;m going to tell you how I roll out EdgeRails projects and in turn show you how to download Rails 2.0RC1 and generate a project with it.</p>
<p>Before I get into it though, I&#8217;m expecting that you have a development environment already running.  I expect that you already have rake, ruby, rails, svn, and all that other stuff installed.  If you don&#8217;t, please see one of the thousand Internet posts on how to do that or the many chapters in books that cover it.  Okay, now that we are on the same page &#8211; let&#8217;s get moving.Let&#8217;s open up your command line terminal.  Go into wherever you create your projects in Rails and make a new directory for your new project:</p>
<pre>mkdir -p new_project/vendor</pre>
<p>The -p variable creates both the new_project directory and the vendor directory inside it (depends of course on your OS, you could always just create both manually).  Go into the directory:</p>
<pre>cd new_project</pre>
<p>Now, run SVN and checkout 2.0RC1 into the vendor/rails directory.</p>
<pre>svn co http://dev.rubyonrails.org/svn/rails/tags/rel_2-0-0_RC1 vendor/rails</pre>
<p>Now from the project directory (new_project) run the rails script within the vendor directory.</p>
<pre>ruby vendor/rails/railties/bin/rails .</pre>
<p>That will execute the rails script on the current directory.  You basically just did the same thing as executing &#8220;rails new_project&#8221;.  That&#8217;s it, you&#8217;ve now checked out Rails 2.0RC1 and created the base project.  Now get started&#8230;Have fun.</p>
<p><em>Update:</em></p>
<p>This morning (November 29th) the Rails team has released RC2 so if you are wanting to check out RC2 &#8211; use the svn checkout command of:</p>
<pre>svn co http://dev.rubyonrails.org/svn/rails/tags/rel_2-0-0_RC2 vendor/rails</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/innovativethought.wordpress.com/48/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/innovativethought.wordpress.com/48/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/innovativethought.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/innovativethought.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/innovativethought.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/innovativethought.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/innovativethought.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/innovativethought.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/innovativethought.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/innovativethought.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/innovativethought.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/innovativethought.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/innovativethought.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/innovativethought.wordpress.com/48/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/innovativethought.wordpress.com/48/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/innovativethought.wordpress.com/48/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=48&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://innovativethought.net/2007/11/28/rolling-with-rails-20rc1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2722012beb9afcad75df5c9f2229fd8c?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Tim Knight</media:title>
		</media:content>
	</item>
		<item>
		<title>Making Configuration Files with YAML</title>
		<link>http://innovativethought.net/2007/07/25/making-configuration-files-with-yaml/</link>
		<comments>http://innovativethought.net/2007/07/25/making-configuration-files-with-yaml/#comments</comments>
		<pubDate>Wed, 25 Jul 2007 15:30:24 +0000</pubDate>
		<dc:creator>Tim Knight</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Configuration]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[YAML]]></category>

		<guid isPermaLink="false">http://innovativethought.wordpress.com/2007/07/25/making-configuration-files-with-yaml/</guid>
		<description><![CDATA[Update: A newer version of how I load YAML into configuration files in my projects can be found here. Since being introduced to YAML I&#8217;ve loved using it for configuration files in both Ruby and Ruby on Rails. YAML means &#8220;YAML Ain&#8217;t Markup Language&#8221;. Yes, there is an infinite loop in the title &#8211; it&#8217;s programmer [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=46&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> A newer version of how I load YAML into configuration files in my projects can be found <a href="http://blog.innovativethought.net/2009/01/02/making-configuration-files-with-yaml-revised/">here</a>.</p>
<p>Since being introduced to YAML I&#8217;ve loved using it for configuration files in both Ruby and Ruby on Rails.  YAML means &#8220;YAML Ain&#8217;t Markup Language&#8221;.  Yes, there is an infinite loop in the title &#8211; it&#8217;s programmer humor.  Those of you familiar with Ruby on Rails are somewhat familiar with YAML because that is the format of the database.yml configuration file.  So this is a sample of what a YAML file typically looks like:</p>
<pre>development:
	adapter: mysql
	database: project_development
	username: root
	password:
	socket: /tmp/mysql.sock</pre>
<p>This is a snippet out of the database.yml file.  But one of the great things about Ruby is that writing code to read YAML is extremely simple.  Let&#8217;s say I want to make a website configuration file, this is what that might look like:</p>
<pre>config:
	title: My Rails Website
	author: Santa Claus
	email: email@company.com
	css_file: default.css</pre>
<p>The hardest part is thinking about what type of information you want to store in your configuration, the Ruby is extremely easy.  Check it out&#8230;</p>
<p>First we require the YAML library:</p>
<pre>require 'yaml'</pre>
<p>Ok, now we can make a read_config method:</p>
<pre>def read_config
	config = YAML.load_file("config.yaml")
	@title = config["config"]["title"]
	@author = config["config"]["author"]
	@email = config["config"]["email"]
	@css_file = config["config"]["css_file"]
end</pre>
<p>Seriously, that&#8217;s it (of course you need to execute the method).  We just load the YAML into a local variable.  Then we spider down the YAML document using the local variable that we assigned the loaded YAML document.  So where you see &#8220;config&#8221; in quotes that is referring to the &#8220;config:&#8221; within the YAML document.  Of course, were I say &#8220;config.yaml&#8221; you would actually put the path to your specific YAML document.  One the information is loaded, I pull the data I want into a few instance variables making them accessible to my views (in Rails).</p>
<p><em>Update:</em></p>
<p>A more efficient way to do this would be to loop through the hash that is created by the read_config method and just set the key to an instance variable, like so:</p>
<pre>config["config"].each { |key, value| instance_variable_set("@#{key}", value) }</pre>
<p><strong>Update:</strong> A newer version of how I load YAML into configuration files in my projects can be found <a href="http://blog.innovativethought.net/2009/01/02/making-configuration-files-with-yaml-revised/">here</a>.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/innovativethought.wordpress.com/46/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/innovativethought.wordpress.com/46/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/innovativethought.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/innovativethought.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/innovativethought.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/innovativethought.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/innovativethought.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/innovativethought.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/innovativethought.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/innovativethought.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/innovativethought.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/innovativethought.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/innovativethought.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/innovativethought.wordpress.com/46/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/innovativethought.wordpress.com/46/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/innovativethought.wordpress.com/46/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=46&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://innovativethought.net/2007/07/25/making-configuration-files-with-yaml/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2722012beb9afcad75df5c9f2229fd8c?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Tim Knight</media:title>
		</media:content>
	</item>
		<item>
		<title>Formatting Names Using Ruby</title>
		<link>http://innovativethought.net/2007/07/18/formatting-names-using-ruby/</link>
		<comments>http://innovativethought.net/2007/07/18/formatting-names-using-ruby/#comments</comments>
		<pubDate>Wed, 18 Jul 2007 23:28:33 +0000</pubDate>
		<dc:creator>Tim Knight</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Formatting]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://innovativethought.wordpress.com/2007/07/18/formatting-names-using-ruby/</guid>
		<description><![CDATA[Getting information from users is a common task that we have to deal with in building an application. This typically happens either in creating a user account, commerce orders, or any other time when the application has to ask &#8220;who are you?&#8221;. Often times we&#8217;ll create a field for both a firstname and a lastname [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=43&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Getting information from users is a common task that we have to deal with in building an application.  This typically happens either in creating a user account, commerce orders, or any other time when the application has to ask &#8220;who are you?&#8221;.  Often times we&#8217;ll create a field for both a firstname and a lastname allowing the user to separate their names to make it easier for us (the application developer) to display either/or both.  In this post, I&#8217;m going to talk about how we can format full names given to the application by the user without necessarily worrying about creating two textfields.  Of course, you would use this code in the methods within a Rails app.</p>
<p>So let&#8217;s say I have a variable for creative purposes, I&#8217;ll call it &#8216;name&#8217; and &#8216;name&#8217; has a value.</p>
<p>name = &#8220;James Earl Jones&#8221;</p>
<p>And I want to only display the first and last name of my &#8216;name&#8217; value I could do this:</p>
<p>names = name.split<br />
firstname = names.first<br />
lastname = names.last</p>
<p>Now this splits the three words in &#8216;name&#8217; into an array.  I then set firstname as the first item from the array, and set lastname as the last item from the array.</p>
<p><strong>Running:</strong><br />
p &#8220;#{firstname} #{lastname}&#8221;</p>
<p><strong>Would then output:</strong><br />
&#8220;James Jones&#8221;</p>
<p>How about we do another common formatting task we can to show the last name first separated with a comma the rest of the name, we could do this:</p>
<p>names = name.split<br />
lastname = names.pop<br />
firstname_remaining = names.join(&#8216; &#8216;)</p>
<p>Here we split the name up again, put then ran the pop method which pulls the last time of the array out of the array and then returns it.  This would leave only the remaining name left to work with as the firstname_remaining variable.  I them join the rest of the array with spaces for the firstname_remaining (which would include the first name and any remain name information like a middle name).</p>
<p><strong>Running:</strong><br />
p &#8220;#{lastname}, #{firstname_remaining}&#8221;</p>
<p><strong>Would then output:</strong><br />
&#8220;Jones, James Earl&#8221;</p>
<p>Lastly, a common thing I&#8217;ve been seeing lately is the usage of the last initial when showing a user&#8217;s name.  We could do something like this:</p>
<p>names = name.split<br />
firstname = names.first<br />
lastinitial = names.last[0,1]</p>
<p>Here I&#8217;m introducing some trimming for the lastinitial variable.  You see this with a bracket and two numbers.  The first number is the offset in the string that I&#8217;m trimming (zero is the first letter is a string), the next number is how many characters I&#8217;m showing from that offset.</p>
<p><strong>Running:</strong><br />
p &#8220;#{firstname} #{lastinitial}.&#8221;</p>
<p><strong>Would then output:</strong><br />
&#8220;James J.&#8221;</p>
<p>So that&#8217;s it for now.  Of course you might think about adapting this to users that will have items at the end of their name like &#8220;Jr.&#8221; &#8211; this can sometimes just be solved using a drop-down.  I&#8217;m hoping that perhaps I have introduced you to some things in Ruby that you might have been previously unaware of.  Until next time.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/innovativethought.wordpress.com/43/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/innovativethought.wordpress.com/43/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/innovativethought.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/innovativethought.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/innovativethought.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/innovativethought.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/innovativethought.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/innovativethought.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/innovativethought.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/innovativethought.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/innovativethought.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/innovativethought.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/innovativethought.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/innovativethought.wordpress.com/43/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/innovativethought.wordpress.com/43/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/innovativethought.wordpress.com/43/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=43&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://innovativethought.net/2007/07/18/formatting-names-using-ruby/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2722012beb9afcad75df5c9f2229fd8c?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Tim Knight</media:title>
		</media:content>
	</item>
		<item>
		<title>Silencing Rails Logs for Security</title>
		<link>http://innovativethought.net/2007/06/12/silencing-rails-logs-for-security/</link>
		<comments>http://innovativethought.net/2007/06/12/silencing-rails-logs-for-security/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 05:07:39 +0000</pubDate>
		<dc:creator>Tim Knight</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://innovativethought.wordpress.com/2007/06/12/silencing-rails-logs-for-security/</guid>
		<description><![CDATA[For those of you that are already familiar with the Rails framework you already know that the Rails logs are completely invaluable when it comes to debugging and troubleshooting issues.  However, just as with any form of transaction logs they introduce a major security issue. Just think about some of that information that you might [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=38&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For those of you that are already familiar with the Rails framework you already know that the Rails logs are completely invaluable when it comes to debugging and troubleshooting issues.  However, just as with any form of transaction logs they introduce a major security issue.</p>
<p>Just think about some of that information that you might be storing in your database&#8230; credit card numbers?, social security numbers?, or what about passwords?  Imagine someone getting a hold of those logs and seeing all the session parameters being passed into the database.  Inserting the credit card numbers into an order, selecting the user information based on a username and password combination.  See the point I&#8217;m making here?  Let&#8217;s look at a quick example of what you&#8217;ll see in your logs:</p>
<p>Parameters: {&#8220;model&#8221;=&gt;{&#8220;username&#8221;=&gt;&#8221;John&#8221;, &#8220;password&#8221;=&gt;&#8221;hax0r&#8221;}&#8230;</p>
<p>Not good.</p>
<p>Thankfully Rails makes it simple to filter this important material from your logs.  Just open up the model that you want to filter and add a single line just below the class definition:</p>
<p>class Model &lt; ActiveRecord::Base<br />
filter_parameter_logging :password<br />
&#8230;<br />
end</p>
<p>In this case I just filtered &#8220;password&#8221;, but you could filter whatever else you wanted to for that model, separating each parameter with a comma, like such:</p>
<p>filter_parameter_logging :password, :confirm_password, :ssn, :creditcard_number, :etc</p>
<p>It&#8217;s that&#8217;s simple.  So keep those Rails logs secure and filter out the stuff that others don&#8217;t need to know.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/innovativethought.wordpress.com/38/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/innovativethought.wordpress.com/38/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/innovativethought.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/innovativethought.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/innovativethought.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/innovativethought.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/innovativethought.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/innovativethought.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/innovativethought.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/innovativethought.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/innovativethought.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/innovativethought.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/innovativethought.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/innovativethought.wordpress.com/38/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/innovativethought.wordpress.com/38/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/innovativethought.wordpress.com/38/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=38&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://innovativethought.net/2007/06/12/silencing-rails-logs-for-security/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2722012beb9afcad75df5c9f2229fd8c?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Tim Knight</media:title>
		</media:content>
	</item>
		<item>
		<title>Using Ruby to Stay Informed With Innovative Thought</title>
		<link>http://innovativethought.net/2007/05/23/using-ruby-to-stay-informed-with-innovative-thought/</link>
		<comments>http://innovativethought.net/2007/05/23/using-ruby-to-stay-informed-with-innovative-thought/#comments</comments>
		<pubDate>Wed, 23 May 2007 05:03:43 +0000</pubDate>
		<dc:creator>Tim Knight</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Feeds]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://innovativethought.wordpress.com/2007/05/23/using-ruby-to-stay-informed-with-innovative-thought/</guid>
		<description><![CDATA[So I was thinking this evening about creating an RSS parser in Ruby. You know&#8230; Ruby supports this built in? Big surprise right? All you have to do in require the rss library: require 'rss' Then of course if you want to open up a connection to a URL you need to include the open [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=23&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So I was thinking this evening about creating an RSS parser in Ruby.  You know&#8230; Ruby supports this built in?  Big surprise right?  All you have to do in require the rss library:</p>
<pre><code>require 'rss'</code></pre>
<p>Then of course if you want to open up a connection to a URL you need to include the open uri library too:</p>
<pre><code>require 'open-uri'</code></pre>
<p>So that&#8217;s all the requirements.  Next I&#8217;ll create a method called ReadRss that will take a single variable defined as &#8220;url&#8221;.</p>
<pre><code>def ReadRss(url)
  open(url) do |page|
    respond = page.read
    result = RSS::Parser.parse(respond,false)
    puts "Blog: #{result.channel.title}, #{result.channel.description}"
    result.items.each_with_index do |item, i|
      i += 1
      puts "#{i}  #{item.title}"
    end
  end
end</code></pre>
<p>That&#8217;s it.  Now all you have to do is call ReadRss with the site feed address.  Here&#8217;s a good hint for you:</p>
<pre><code>ReadRss("http://innovativethought.wordpress.com/feed/")</code></pre>
<p>So now that you can parse RSS feeds right from your Ruby script.  ATOM parser will come shortly.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/innovativethought.wordpress.com/23/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/innovativethought.wordpress.com/23/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/innovativethought.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/innovativethought.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/innovativethought.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/innovativethought.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/innovativethought.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/innovativethought.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/innovativethought.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/innovativethought.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/innovativethought.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/innovativethought.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/innovativethought.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/innovativethought.wordpress.com/23/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/innovativethought.wordpress.com/23/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/innovativethought.wordpress.com/23/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=innovativethought.net&#038;blog=965151&#038;post=23&#038;subd=innovativethought&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://innovativethought.net/2007/05/23/using-ruby-to-stay-informed-with-innovative-thought/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2722012beb9afcad75df5c9f2229fd8c?s=96&#38;d=&#38;r=G" medium="image">
			<media:title type="html">Tim Knight</media:title>
		</media:content>
	</item>
	</channel>
</rss>
