<?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>Conceptric &#187; ruby on rails</title>
	<atom:link href="http://www.conceptric.co.uk/tag/ruby-on-rails/feed" rel="self" type="application/rss+xml" />
	<link>http://www.conceptric.co.uk</link>
	<description>Ideas and Applications</description>
	<lastBuildDate>Fri, 12 Aug 2011 13:00:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Evolving style after six months on Rails</title>
		<link>http://www.conceptric.co.uk/evolving-style-after-six-months-on-rails.htm</link>
		<comments>http://www.conceptric.co.uk/evolving-style-after-six-months-on-rails.htm#comments</comments>
		<pubDate>Thu, 04 Feb 2010 17:31:08 +0000</pubDate>
		<dc:creator>James Whinfrey</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.conceptric.co.uk/?p=331</guid>
		<description><![CDATA[It's coming up to 6 months since I announced my transition from PHP to Ruby and I'm really getting the hang of my new web development toolkit by working on a personal project.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ruby-lang.org/en/">Ruby</a> which is an interpreted programming language, often called a scripting language, that I&#8217;ve been using alongside BASH for automating tasks on my Mac. Call me slow&#8230; no don&#8217;t, I&#8217;m quite sensitive, but I only recently coupled this with the Rails web <a href="http://en.wikipedia.org/wiki/Software_framework">software framework</a> and started working on a Ruby on Rails web application.</p>

<p>There&#8217;s no better way to learn a new language than to actually use it in real life. My Nature Notes started as a project for my partner in PHP, CodeIgniter actually, but progress was slow due to an enjoyment deficit.</p>

<p>Testing is the main reason that I grew unhappy with PHP, most of the tools were there, but the integration was patchy: the basics are all there in Ruby and it&#8217;s associated development frameworks and integrating new packages via ruby gems or plugins is simple.</p>

<p>I started using the built-in Rails testing tools, but for no particular reason I&#8217;ve moved on to <a href="http://rspec.info/">RSpec</a> for unit and functional Rails model and standalone Ruby code testing coupled with <a href="http://cukes.info/">Cucumber</a> based integration testing. I&#8217;ve found that I need both.</p>

<p>Cucumber tests try to exercise the whole software stack &#8211; views, controllers, models and even the database. The use of natural language makes it easier to translate user stories into the appropriate tests, though it still needs some discipline to ensure that the edge cases are covered: I don&#8217;t think clients could write these as acceptance tests.</p>

<p>Involving the whole stack makes tests a little brittle, how specific is too specific? I&#8217;ve managed to break tests by removing fullstops (periods) from the rendered HTML!</p>

<p>I think that this is where unit and functional testing with RSpec at the model level is indispensable. I test model associations, validations and custom business logic in that order, I draw the limit at all the ActiveRecord <abbr title="Create Read Update Delete">CRUD</abbr> functionality.</p>

<p>I&#8217;ve found that the development environment hasn&#8217;t really changed in the move, the same basic toolkit does PHP and Ruby.</p>

<p>I regularly use several code version control systems including Subversion, Git and Mercurial. Recently though I&#8217;ve increasingly turned to Git and GitHub. Like most good tools the more you use it the more attached you become, so I&#8217;ll have to force myself to use the equally fine Mercurial again soon. I love these distributed tools.</p>

<p>TextMate is my editor of choice for Rails development. I&#8217;ve tried to use Netbeans <abbr title="Integrated Development Environment">IDE</abbr>, I use this for Java, but it seems like overkill. TextMate is quicker, simpler and provides the tools I need via the a range of bundles.</p>

<p>I have to admit that the code syntax highlighting is the most useful feature because I like using the command line too much, but I&#8217;m increasingly using code completion and I&#8217;m going to try the <a href="http://code.google.com/p/zen-coding/">Zen coding</a> bundles for HTML and CSS, I don&#8217;t like the default tools much.</p>

<p>That&#8217;s a round up of my current practice, more about the resulting software once I&#8217;ve decided to move on to a public beta.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conceptric.co.uk/evolving-style-after-six-months-on-rails.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How does behaviour drive development?</title>
		<link>http://www.conceptric.co.uk/how-does-behaviour-drive-development.htm</link>
		<comments>http://www.conceptric.co.uk/how-does-behaviour-drive-development.htm#comments</comments>
		<pubDate>Thu, 12 Nov 2009 13:25:23 +0000</pubDate>
		<dc:creator>James Whinfrey</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[processes]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.conceptric.co.uk/?p=310</guid>
		<description><![CDATA[Behaviour Driven Development (BDD) is an adaptation of earlier Test Driven practices (TDD) that's growing on me, but it's raised an interesting problem: the order in which to describe desired behaviour so that it actually drives development.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve only recently started dabbling in <abbr title="Behaviour Driven Development">BDD</abbr> using <a href="http://railscasts.com/episodes/155-beginning-with-cucumber">Cucumber and RSpec in Rails</a> applications. It feels quite different to the <abbr title="Test Driven Development">TDD</abbr> practices I&#8217;ve adopted before in Java, PHP or Ruby.</p>

<p>It feels like I&#8217;m starting from the top of the software stack and working down from broad specifications, creating code as I go, rather than up from fine grained models based on specific unit tests. Is this a reductionist approach?</p>

<p>When writing my features and scenarios I&#8217;ve noticed a tendency to follow the <abbr title="Create Read Update Delete">CRUD</abbr> acronym common in data access layers: Create Read Update and Delete. The order of these processes is significant and my reasoning goes something like this&#8230;&#8230;</p>

<p>I can&#8217;t really expect to read the contents of an entity before I&#8217;ve generated the code to create it. Now I&#8217;ve created it, I&#8217;m not going to try to edit this same entity unless I can actually read it. I can read what I&#8217;ve got, but I might want to edit those contents, and delete comes last&#8230;&#8230; because it just does, I guess the order of &#8220;UD&#8221; is negotiable, but this way it&#8217;s easier to pronounce.</p>

<p>You get the general picture, but this is just the approach I&#8217;ve adopted through trial and lots of error. It&#8217;s far from perfect, so how do you use behaviour to lead the code?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conceptric.co.uk/how-does-behaviour-drive-development.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Another Snow Leopard upgrade story</title>
		<link>http://www.conceptric.co.uk/another-snow-leopard-upgrade-story.htm</link>
		<comments>http://www.conceptric.co.uk/another-snow-leopard-upgrade-story.htm#comments</comments>
		<pubDate>Thu, 29 Oct 2009 17:26:49 +0000</pubDate>
		<dc:creator>James Whinfrey</dc:creator>
				<category><![CDATA[Mac User]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[snow leopard]]></category>
		<category><![CDATA[upgrade]]></category>

		<guid isPermaLink="false">http://www.conceptric.co.uk/?p=308</guid>
		<description><![CDATA[The time had come to upgrade our MacBook Pros to Snow Leopard. Not wishing to break my partner's laptop, I decided to see if the upgrade route would work using my machine as a testbed. Would I live to regret it...]]></description>
			<content:encoded><![CDATA[<p>It may be that I&#8217;m a little paranoid, but I spent a full half day updating backups and two separate, and tested, clones of my main drive partition using <a href="http://www.shirt-pocket.com/SuperDuper/SuperDuperDescription.html">SuperDuper</a>.</p>

<p>This complete, I pushed the Mac OS X Snow Leopard Family Pack upgrade disc into the drive, and after a quick read, I&#8217;d signed away my life to Apple, pressed the install button, and found something else to do for the next hour.</p>

<p>I&#8217;d checked that all my key applications were compliant with Snow Leopard before I started, so the mainstream upgrade process was pretty painless: very promising for my chances of surviving my next upgrade.</p>

<p>I also remembered to install Xcode and the developer tools, vital for the next step.</p>

<h3>The Pain of the Developer.</h3>

<p>The problems started with the developer environment I&#8217;ve become accustom to using: PHP and Ruby. I started to wonder whether a clean install might have been a better idea.</p>

<p>I&#8217;m happy using the bundled Apache and PHP at the moment; these have been upgraded to versions 2.2.11 and 5.3 respectively, so there&#8217;s no major drama until they need to connect to MySQL.</p>

<p>Conversely, I prefer to build the majority of my tools from source in the <code>/usr/local</code> directory: MySQL, Ruby, RubyGems and Git.</p>

<p>Dan Benjamin has a <a href="http://hivelogic.com/categories/software">great set of posts to help you</a> do this, but he starts with a clean install, and if you&#8217;re upgrading it might not go so smoothly. Here are a few pointers gleaned from the Web and personal experience.</p>

<h3>A new MySQL build.</h3>

<p>I&#8217;ve been using version 5.0.51a for a while and decided to upgrade to 5.1.39 as part of the whole process. The first step was to create a dumpfile of the old database to upload into the new version:</p>

<p><code class="terminal">mysqldump --opt -uroot -p --all-databases > currentdatabasedump.sql</code></p>

<p>In my experience, following <a href="http://hivelogic.com/articles/compiling-mysql-on-snow-leopard/">Dan&#8217;s instructions</a> gives great results, but I install each version into its own directory and symbolic link the one I want to use:</p>

<p><code class="terminal">lrwxr-xr-x    1 root  wheel    12 28 Oct 16:05 mysql -> mysql-5.1.39
drwxr-xr-x   12 root  wheel   408 28 Oct 13:24 mysql-5.0.51a
drwxr-xr-x   10 root  wheel   340 28 Oct 16:07 mysql-5.1.39
</code></p>

<p>Now to load the old databases into the new management system, so I logged in as root:</p>

<p><code class="terminal">mysql -uroot</code></p>

<p>notice there&#8217;s no password yet, and from the mysql command line I loaded the contents of the dumpfile:</p>

<p><code class="terminal">source path/to/dumpfile/currentdatabasedump.sql;</code></p>

<p>Finally, the databases need to be checked for incompatibilities and upgraded:</p>

<p><code class="terminal">mysql_upgrade</code></p>

<p>and the database was acting like the old one, with the expected users and passwords assigned.</p>

<h4>Why PHP still can&#8217;t use MySQL.</h4>

<p>Snow Leopard doesn&#8217;t come with a <code>php.ini</code> file, so I copied <code>/etc/php.ini.default</code>  to <code>/etc/php.ini</code>, but this file still needed a little modification to work with MySQL.</p>

<p>I changed all the occurrences of <code>/var/mysql/mysql.sock</code> to <code>/tmp/mysql.sock</code>, restarted Apache and my local WordPress installations were back in action, but MediaWiki wasn&#8217;t.</p>

<p>At this point the irony of having my troubleshooting notes in the form of a local wiki struck home, fortunately an upgrade to MediaWiki version 1.15.1 solved the problem.</p>

<h3>Building Ruby, Rails and Gems.</h3>

<p>I based my attempt on <a href="http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard/">Dan&#8217;s instructions</a>, and this time I was greeted by a series of <code>make</code> errors from <code>readline</code>.</p>

<p><a href="http://blog.robseaman.com/2008/12/10/from-ruby-1-8-6-to-1-87-and-back-again-on-leopard">Rob Seaman sums them up nicely</a> and making the suggested adjustments to <code>config.h</code> allowed me to complete the installation.</p>

<p>I also tried to uninstall <code>readline</code>, but this only resulted in more errors, so pragmatically I upgraded to <code>readline 6.0</code>, and stuck to with the file modifications; must solve this problem one day&#8230;</p>

<p>Back to Dan for RubyGems, and installing the MySQL gem, and the first leg of the job was complete.</p>

<h4>Rebuilding all the other gems.</h4>

<p>Time to upgrade every gem, and <code>gem update</code> won&#8217;t do the job, they all need to be reinstalled. I picked up this handy line of Ruby code that can be run in <code>irb</code> from <a href="http://blog.costan.us/2009/07/rebuild-your-ruby-gems-if-you-update-to.html">Victor Costan&#8217;s blog</a>:</p>

<p><code class="terminal"><code>gem list</code>.each_line {|line| system "sudo gem install #{line.split.first}"}</code></p>

<p>It executes the <code>gem install</code> command for every gem on your existing local list, and it was at this point that I noticed that the arrow keys were behaving strangely in <code>irb</code>.</p>

<p>It turns out that the <code>readline</code> extension isn&#8217;t installed along with the rest of Ruby:</p>

<p><code class="terminal">cd /usr/local/src/ruby-1.8.7-p174/ext/readline
ruby extconf.rb
make
sudo make install
</code></p>

<p>should fix the problem.</p>

<h4>The fly in the ointment.</h4>

<p>Everything was going great, but whilst building the Nokogiri gem I ran into more errors. As <a href="http://rogerneel.posterous.com/snow-leopard-rails-headaches">Roger Neel worked out</a>, I also tracked the problem to MacPorts, and the thing is that I can&#8217;t remember why it&#8217;s installed in the first place! So I took a risk, cloned first of course, and removed all traces of MacPorts:</p>

<p><code class="terminal">sudo port -f uninstall installed</code></p>

<p>No good, MacPorts was too broken to uninstall itself, so next I took the direct approach:</p>

<p><code class="terminal">sudo rm -rf /opt/local \
/Applications/MacPorts \
/Applications/DarwinPorts \
/Library/Tcl/macports1.0 \
/Library/Tcl/darwinports1.0 \
/Library/LaunchDaemons/org.macports.* \
/Library/StartupItems/DarwinPortsStartup \
/Library/Receipts/MacPorts<em>.pkg \
/Library/Receipts/DarwinPorts</em>.pkg \
~/.macports
</code></p>

<p>Gone, and with it the Nokogiri compilation errors, I can&#8217;t help wondering whether I&#8217;ll regret this step later&#8230; when I figure out why I installed it in the first place.</p>

<h4>Building and installing Passenger.</h4>

<p>Like all the gems, Passenger needs to be rebuilt using the new <code>gcc</code> compiler bundled with Xcode. My original Passenger configuration file disappeared from the <code>/etc/apache2/other</code> directory during the upgrade, so I made a new one:</p>

<p><code class="terminal">-r--r--r--  1 root  wheel   73 18 May 20:44 bonjour.conf
-rw-r--r--  1 root  wheel  287 28 Oct 20:06 passenger.conf
-r--r--r--  1 root  wheel  194 18 May 20:44 php5.conf
</code></p>

<p>This file contains the configuration instructions given at the end of the Passenger installation invoked by:</p>

<p><code class="terminal">passenger-install-apache2-module</code></p>

<h3>And Git.</h3>

<p>Followed <a href="http://hivelogic.com/articles/compiling-git-on-snow-leopard/">Dan&#8217;s recommendations</a> and there were no problems.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conceptric.co.uk/another-snow-leopard-upgrade-story.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Switching to Rails</title>
		<link>http://www.conceptric.co.uk/switching-to-rails.htm</link>
		<comments>http://www.conceptric.co.uk/switching-to-rails.htm#comments</comments>
		<pubDate>Sun, 30 Aug 2009 18:30:00 +0000</pubDate>
		<dc:creator>James Whinfrey</dc:creator>
				<category><![CDATA[Personal Perspectives]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.conceptric.co.uk/?p=302</guid>
		<description><![CDATA[I know that a good developer should choose the best tool for the job in hand, but their own productivity and inspiration must inform the decision in selecting the best tool.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a personal project based on CodeIgniter and it&#8217;s been uphill work. I finally lost patience with both the framework and language and followed the advice given on <a href="http://www.conceptric.co.uk/codeigniter-test-coverage.htm">my last post about code testing</a>.</p>

<p>I&#8217;ve used Ruby for scripting, and deploying PHP applications with custom Capistrano recipes for years now, but I&#8217;ve never tried any of the available web frameworks.</p>

<p>This week I switched to Ruby on Rails, and I&#8217;ve accomplished more in a couple of days than in a couple of months with CodeIgniter.</p>

<p>I&#8217;m not trying to claim that there&#8217;s anything fundamentally wrong with PHP, so don&#8217;t beat me up over it, but I find working with Ruby and Java much more intuitive, enjoyable and productive: it&#8217;s a personal choice, I feel more inspired.</p>

<p>I&#8217;m particularly loving the default support for <a href="http://guides.rubyonrails.org/testing.html">unit, functional and integration testing</a>; I now feel in control of my code and I&#8217;ve yet to explore the full range of testing frameworks and approaches available for Rails.</p>

<p>I know that <a href="http://cakephp.org/">CakePHP</a> mirrors Rails functionality very closely, but I&#8217;m afraid it&#8217;s the PHP language that I find too ugly to love &#8211; personal choice again, don&#8217;t shoot &#8211; consequently this is one developer who may have written his last line of PHP code&#8230;&#8230; maybe.</p>

<p>I&#8217;m now hoping to have the first release of the nature and wildlife recording application I&#8217;ve been promising Clare for&#8230;&#8230; much too long, up and running in the next couple of weeks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conceptric.co.uk/switching-to-rails.htm/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

