<?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/"
	>

<channel>
	<title></title>
	<atom:link href="http://thunderdata.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://thunderdata.com/blog</link>
	<description>TDS - General Business, Programming and Code, Ideas for the Web</description>
	<pubDate>Thu, 07 Jan 2010 22:03:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Rails validation error not displaying - validates_presence_of, error_message_for</title>
		<link>http://thunderdata.com/blog/category/rails-gotchas-validates_presence_on-error_message_for-display-failure/</link>
		<comments>http://thunderdata.com/blog/category/rails-gotchas-validates_presence_on-error_message_for-display-failure/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 21:26:22 +0000</pubDate>
		<dc:creator>Dawn</dc:creator>
		
		<category><![CDATA[TDS Developer's Corner]]></category>

		<category><![CDATA[error object redirect problem]]></category>

		<category><![CDATA[error validation failure]]></category>

		<category><![CDATA[errors do not display]]></category>

		<category><![CDATA[error_messages_on]]></category>

		<category><![CDATA[rails render versus redirect]]></category>

		<category><![CDATA[Rails validations]]></category>

		<category><![CDATA[Ruby on Rails]]></category>

		<category><![CDATA[validate model]]></category>

		<category><![CDATA[validates_presence_on]]></category>

		<guid isPermaLink="false">http://thunderdata.com/blog/?p=174</guid>
		<description><![CDATA[Rails gotcha doesn't display validation errors when using redirects after validation execution.  Change the redirect to "render :action => 'method'" to handle error display.]]></description>
			<content:encoded><![CDATA[<p>I hit a wall recently as I tried to track down the reason <span style='font-family: Courier New;'> validates_presence_of </span> was not displaying errors.  Rails validations normally go off without a hitch, so I was a bit stumped when my attempts to save blank fields were not triggering the appropriate messages.  After ensuring my model and view were correct, I fired up the console to make sure my validations were working in the first place.  After loading an object and attempting a save, I checked to see if the errors object returned false.  Sure enough, all of the validations were enforced.</p>

<pre>
<code>
>> @contact = Contact.find_by_id(9)
=> #<Contact id: 9, user_id: 9, first_name: nil, middle: nil, last_name: nil, address: nil, apt_or_suite: nil, city: nil, state: nil, zip: nil, phone1: nil, phone2: nil, created_at: "2010-01-07 07:45:32", updated_at: "2010-01-07 07:45:32">
>> @contact.save
=> false
>> @contact.errors.empty?
=> false
>> @contact.errors.count
=> 6
>> @contact.errors.each_full { |msg| puts msg }
   City No blanks
   Zip No blanks
   First name No blanks
   Address No blanks
   Last name No blanks
   State No blanks
</code>
</pre>

<p>After more head banging, I was ready to give up with a simple notification workaround on the update method.</p>

<pre>
<code>
if !@contact.errors.empty?
  flash[:error] = "You are missing required fields."
  redirect_to edit_contact_url(@contact.user)
else
  flash[:notice] = "Successfully saved."
  redirect_to contact_url(@contact.user)
end
</code>
</pre>

<p>That works, but it doesn&#8217;t take advantage of the Rails&#8217; <span style='font-family: Courier New;'>error_messages_for</span> helper to display helpful messages and highlight problem fields.  Then I realized the initial error.  During redirects, the object&#8217;s data isn&#8217;t passed, so while the validations were enforced (the form data would not save upon submission), no errors were being output to the screen.  My new code rendered the page along with the error messages:</p>

<pre>
<code>
if !@contact.errors.empty?
  render :action =&gt; 'edit'
else
  flash[:notice] = "Successfully saved."
  redirect_to contact_url(@contact.user)
end
</code>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://thunderdata.com/blog/category/rails-gotchas-validates_presence_on-error_message_for-display-failure/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Magnets in a Digital World: Credit Card Swipe Processing</title>
		<link>http://thunderdata.com/blog/category/magnets-in-a-digital-world-credit-card-swipe-processing/</link>
		<comments>http://thunderdata.com/blog/category/magnets-in-a-digital-world-credit-card-swipe-processing/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 19:37:31 +0000</pubDate>
		<dc:creator>gary</dc:creator>
		
		<category><![CDATA[Random Business Thoughts]]></category>

		<guid isPermaLink="false">http://thunderdata.com/blog/?p=168</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://thunderdata.com/blog/category/magnets-in-a-digital-world-credit-card-swipe-processing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Marketing in Down Times</title>
		<link>http://thunderdata.com/blog/category/marketing-in-down-times/</link>
		<comments>http://thunderdata.com/blog/category/marketing-in-down-times/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 15:01:54 +0000</pubDate>
		<dc:creator>Dawn</dc:creator>
		
		<category><![CDATA[Random Business Thoughts]]></category>

		<category><![CDATA[budget]]></category>

		<category><![CDATA[consumers]]></category>

		<category><![CDATA[economy]]></category>

		<category><![CDATA[effective advertising]]></category>

		<category><![CDATA[effective marketing]]></category>

		<category><![CDATA[marketing]]></category>

		<category><![CDATA[marketing in a down economy]]></category>

		<category><![CDATA[marketing in a tough economy]]></category>

		<category><![CDATA[tropican orange juice]]></category>

		<guid isPermaLink="false">http://thunderdata.com/blog/?p=142</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://thunderdata.com/blog/category/marketing-in-down-times/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Can Management Understand Employee Needs?</title>
		<link>http://thunderdata.com/blog/category/can-management-understand-employee-needs/</link>
		<comments>http://thunderdata.com/blog/category/can-management-understand-employee-needs/#comments</comments>
		<pubDate>Sat, 30 May 2009 04:40:47 +0000</pubDate>
		<dc:creator>Dawn</dc:creator>
		
		<category><![CDATA[Team Dynamics]]></category>

		<category><![CDATA[developer relationships]]></category>

		<category><![CDATA[disparage employer]]></category>

		<category><![CDATA[employee roles]]></category>

		<category><![CDATA[interpersonal relationships]]></category>

		<category><![CDATA[leadership]]></category>

		<category><![CDATA[management]]></category>

		<category><![CDATA[management relationships]]></category>

		<category><![CDATA[success]]></category>

		<guid isPermaLink="false">http://thunderdata.com/blog/?p=98</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://thunderdata.com/blog/category/can-management-understand-employee-needs/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Altering Course: Development Team and Client Relationships</title>
		<link>http://thunderdata.com/blog/category/changing-course-team-priorities-and-client-relationships/</link>
		<comments>http://thunderdata.com/blog/category/changing-course-team-priorities-and-client-relationships/#comments</comments>
		<pubDate>Thu, 21 May 2009 04:53:08 +0000</pubDate>
		<dc:creator>Dawn</dc:creator>
		
		<category><![CDATA[Team Dynamics]]></category>

		<category><![CDATA[agile practices]]></category>

		<category><![CDATA[agile programming environment]]></category>

		<category><![CDATA[client relationships]]></category>

		<category><![CDATA[programmers and project manager relations]]></category>

		<category><![CDATA[scrum]]></category>

		<category><![CDATA[team environment]]></category>

		<category><![CDATA[team programming]]></category>

		<guid isPermaLink="false">http://thunderdata.com/blog/?p=87</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://thunderdata.com/blog/category/changing-course-team-priorities-and-client-relationships/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RailsConf Retrospectives, Part 1: Testing</title>
		<link>http://thunderdata.com/blog/category/railsconf-retrospectives-part-1-testing/</link>
		<comments>http://thunderdata.com/blog/category/railsconf-retrospectives-part-1-testing/#comments</comments>
		<pubDate>Mon, 11 May 2009 18:27:44 +0000</pubDate>
		<dc:creator>gary</dc:creator>
		
		<category><![CDATA[TDS Developer's Corner]]></category>

		<guid isPermaLink="false">http://thunderdata.com/blog/?p=76</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://thunderdata.com/blog/category/railsconf-retrospectives-part-1-testing/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Fixing a Dysfunctional Team</title>
		<link>http://thunderdata.com/blog/category/fixing-a-dysfunctional-team/</link>
		<comments>http://thunderdata.com/blog/category/fixing-a-dysfunctional-team/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 03:00:05 +0000</pubDate>
		<dc:creator>Dawn</dc:creator>
		
		<category><![CDATA[Team Dynamics]]></category>

		<category><![CDATA[agile team development]]></category>

		<category><![CDATA[cats and dogs]]></category>

		<category><![CDATA[developer relationships]]></category>

		<category><![CDATA[dysfunctional team]]></category>

		<category><![CDATA[human resources]]></category>

		<category><![CDATA[programmers and project manager relations]]></category>

		<category><![CDATA[software development]]></category>

		<guid isPermaLink="false">http://thunderdata.com/blog/?p=79</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://thunderdata.com/blog/category/fixing-a-dysfunctional-team/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Show Something Useful</title>
		<link>http://thunderdata.com/blog/category/show-something-useful/</link>
		<comments>http://thunderdata.com/blog/category/show-something-useful/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 22:30:04 +0000</pubDate>
		<dc:creator>gary</dc:creator>
		
		<category><![CDATA[TDS Developer's Corner]]></category>

		<guid isPermaLink="false">http://thunderdata.com/blog/?p=72</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://thunderdata.com/blog/category/show-something-useful/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Catch-all Routes in Rails</title>
		<link>http://thunderdata.com/blog/category/catch-all-routes-in-rails/</link>
		<comments>http://thunderdata.com/blog/category/catch-all-routes-in-rails/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 18:47:54 +0000</pubDate>
		<dc:creator>Nick</dc:creator>
		
		<category><![CDATA[TDS Developer's Corner]]></category>

		<category><![CDATA[404 redirects]]></category>

		<category><![CDATA[404 redirects with rails]]></category>

		<category><![CDATA[handling 404]]></category>

		<category><![CDATA[rails]]></category>

		<category><![CDATA[rails redirects]]></category>

		<category><![CDATA[rails routes]]></category>

		<category><![CDATA[rails tips]]></category>

		<category><![CDATA[rails tricks]]></category>

		<category><![CDATA[redirects]]></category>

		<category><![CDATA[routes]]></category>

		<guid isPermaLink="false">http://thunderdata.com/blog/category/catch-all-routes-in-rails/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://thunderdata.com/blog/category/catch-all-routes-in-rails/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Rails vs PHP</title>
		<link>http://thunderdata.com/blog/category/rails-vs-php/</link>
		<comments>http://thunderdata.com/blog/category/rails-vs-php/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 22:51:31 +0000</pubDate>
		<dc:creator>Paul</dc:creator>
		
		<category><![CDATA[Random Business Thoughts]]></category>

		<guid isPermaLink="false">http://thunderdata.com/blog/category/rails-vs-php/</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[]]></content:encoded>
			<wfw:commentRss>http://thunderdata.com/blog/category/rails-vs-php/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
