<?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>Mike's Blog &#187; Rails</title>
	<atom:link href="http://www.mikeheijmans.com/category/tech/web/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikeheijmans.com</link>
	<description>A site about everything and nothing at all</description>
	<lastBuildDate>Mon, 27 Sep 2010 04:54:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Write tests and save time</title>
		<link>http://www.mikeheijmans.com/2009/08/write-tests-and-save-time/</link>
		<comments>http://www.mikeheijmans.com/2009/08/write-tests-and-save-time/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 23:12:21 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.mikeheijmans.com/?p=148</guid>
		<description><![CDATA[I never could understand why developers didn&#8217;t write tests. The concept of a test is simple. You write a little extra code now that tests the outcome you want or have so that, in the future, when you add a feature or decide to refactor into something simpler or better, you know that you didn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I never could understand why developers didn&#8217;t write tests. The concept of a test is simple. You write a little extra code now that tests the outcome you want or have so that, in the future, when you add a feature or decide to refactor into something simpler or better, you know that you didn&#8217;t break anything without having to walk through all the test cases by hand.</p>
<p>There are two approaches to writing tests and one of them is more conducive to test writing then the other.</p>
<p>The first way is to write your application code first then write the tests to back it up. The first problem with this is a matter of motivation really. After writing all the application code and making it work, I find it very hard to motivate myself to write the little extra bit of tests instead of diving right in to the new feature on the roadmap. Why write the tests after you know it works? Well, again, what if you have to wedge a feature in there or refactor? Then you have to recall all the stuff that you tested by hand while you were building it and then test it again, by hand, or write tests at that point and Murphy&#8217;s law says that you will forget at least one critical case the second time around.  That is why the second choice is the better.</p>
<p>The second way to develop with tests is to write the tests for the functionality that you want and then write the code to make the tests pass. This is the Agile approach and, in my opinion, the better. Why? Well, you are writing tests based on requirements. So you will know as soon as your code does what you want. Second, you are writing tests based on what you are encountering while writing the application. This lends itself to more coverage because you will be writing tests for all the little edge cases you will encounter while writing the application. This means that, in the future, when you refactor or go muddling around, you can verify, RIGHT THEN, if you broke anything.</p>
<p>I have heard managers complain about developers spending time on tests and not on features first because users and clients won&#8217;t see the tests and time should be spent on user/client features. Well, here is the reality, a little time spent at the beginning of a project writing tests saves a lot of time in the end because you don&#8217;t need to spend so much time verifying feature requirements while writing. Plus the QA process is much faster and smoother because you are handing of working code from the beginning. Writing tests at the beginning usually saves me more than 10% time on the same project where I write the application code only with no tests! That is 10% faster to release and ensures better user experience in the long run because I verified that the project is doing what it should and handling errors properly before I even wrote the application!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikeheijmans.com/2009/08/write-tests-and-save-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Damnit Bluehost and your gem updates!</title>
		<link>http://www.mikeheijmans.com/2009/07/damnit-bluehost-and-your-gem-updates/</link>
		<comments>http://www.mikeheijmans.com/2009/07/damnit-bluehost-and-your-gem-updates/#comments</comments>
		<pubDate>Thu, 09 Jul 2009 23:31:12 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.mikeheijmans.com/2009/07/damnit-bluehost-and-your-gem-updates/</guid>
		<description><![CDATA[I host some stuff with bluehost and I have to say that I am pretty fed up with them and shared hosting! I know shared hosting is never a good idea but for something as simple as http://isitabugorfeature.com it should be a non-issue. Bluehost has &#8220;rails support&#8221; but the assholes keep updating gems without letting [...]]]></description>
			<content:encoded><![CDATA[<p>I host some stuff with bluehost and I have to say that I am pretty fed up with them and shared hosting! I know shared hosting is never a good idea but for something as simple as http://isitabugorfeature.com it should be a non-issue. Bluehost has &#8220;rails support&#8221; but the assholes keep updating gems without letting anyone know and there isn&#8217;t a list or anything I can subscribe to that would let me know about these sort of very relevant updates. I have been burned again.</p>
<p>Today someone mentioned to me that bug or feature was down and I logged in and found that, sure enough, they had updated the rails gem. So I changed my gem requirement in my environment.rb file but my app relies on some 2.2.2 specific stuff so it wouldn&#8217;t start. So, I am forced to get the rails-2.2.2 tag from github and put it in vendor/rails to get the site back up again. I am so tired of this. I am done with bluehost and shared hosting. I am going to begin migrating everything to my slicehost slices and call it a day.</p>
<p>Goodbye bluehost, I would love to say it was all great but I can&#8217;t&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikeheijmans.com/2009/07/damnit-bluehost-and-your-gem-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting TinyUrl&#8217;s in Rails</title>
		<link>http://www.mikeheijmans.com/2008/09/getting-tinyurls-in-rails/</link>
		<comments>http://www.mikeheijmans.com/2008/09/getting-tinyurls-in-rails/#comments</comments>
		<pubDate>Thu, 04 Sep 2008 22:59:49 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Tech]]></category>

		<guid isPermaLink="false">http://www.mikeheijmans.com/?p=103</guid>
		<description><![CDATA[If you have used twitter I am sure you have noticed that if you post a long url in your update it gets turned in to a tinyurl for you. This is really cool functionality and I have created a helper in rails to do it for me. First, let&#8217;s talk about how you get [...]]]></description>
			<content:encoded><![CDATA[<p>If you have used twitter I am sure you have noticed that if you post a long url in your update it gets turned in to a tinyurl for you. This is really cool functionality and I have created a helper in rails to do it for me.</p>
<p>First, let&#8217;s talk about how you get a tinyurl. Tinyurl has a really simple api that you can call that will return a tiny url. It is rediculous how simple it is. You just call this url with a GET: http://tinyurl.comapi-create.php?url=http://example.com</p>
<p>The returned page will be a single line with the tinyurl equivalent. It is that simple. Now on to the rails part.</p>
<p>In your application.rb helper you would add this:</p>
<p>require &#8216;net/http&#8217;<br />
require &#8216;uri&#8217;</p>
<p>def tinyfy(newurl)<br />
&nbsp;&nbsp;&nbsp;url = URI.parse(&#8216;http://tinyurl.com/&#8217;)<br />
&nbsp;&nbsp;&nbsp;res = Net::HTTP.start(url.host, url.port) {|http|<br />
&nbsp;&nbsp;&nbsp;http.get(&#8216;/api-create.php?url=&#8217; + newurl)<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;if res.body.empty?<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#tinyurl is not responding properly&#8230; Return the original url<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return newurl<br />
&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return res.body<br />
&nbsp;&nbsp;&nbsp;end<br />
end</p>
<p>
Now if you call the tinyfy method in your app, let&#8217;s say in your view, with the url you want to tinyurlify as the parameter the return will be the tinyurl. I take this one step further and have the tinyfy method make the url a link by adding the &#8216;a&#8217; tags in the method like so:</p>
<p>require &#8216;net/http&#8217;<br />
require &#8216;uri&#8217;</p>
<p>def tinyfy(newurl)<br />
&nbsp;&nbsp;&nbsp;url = URI.parse(&#8216;http://tinyurl.com/&#8217;)<br />
&nbsp;&nbsp;&nbsp;res = Net::HTTP.start(url.host, url.port) {|http|<br />
&nbsp;&nbsp;&nbsp;http.get(&#8216;/api-create.php?url=&#8217; + newurl)<br />
&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;if res.body.empty?<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#tinyurl is not responding properly&#8230; Return the original url<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return &#8216;&lt;a href=&#8217; + newurl + &#8216;&gt;&#8217; + newurl + &#8216;&lt;/a&gt;&#8217;<br />
&nbsp;&nbsp;&nbsp;else<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return &#8216;&lt;a href=&#8217; + res.body + &#8216;&gt;&#8217; + res.body + &#8216;&lt;/a&gt;&#8217;<br />
&nbsp;&nbsp;&nbsp;end<br />
end</p>
<p>
That will return a nice linked tinyurl in your view. That is all there is to it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikeheijmans.com/2008/09/getting-tinyurls-in-rails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

