<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>tekin.co.uk - Ruby on Rails developer, Tekin Suleyman, Manchester UK</title>
 <link href="http://tekin.co.uk/atom.xml" rel="self"/>
 <link href="http://tekin.co.uk/"/>
 <updated>2009-06-30T17:06:04+01:00</updated>
 <id>http://tekin.co.uk/</id>
 <author>
   <name>Tekin Suleyman</name>
   <email>tekin@tekin.co.uk</email>
 </author>

 
 <entry>
   <title>New in Rails 2.3 - Disabled option tags and lambdas for selecting and disabling options from collections</title>
   <link href="http://tekin.co.uk/:year/:month/:title"/>
   <updated>2009-03-06T00:00:00+00:00</updated>
   <id>http://tekin.co.uk/:year/:month/new-in-rails-23-disabled-option-tags-and-lambdas-for-selecting-and-disabling-options-from-collections</id>
   <content type="html">&lt;p&gt;As it seems to have slipped through the &lt;a href="http://weblog.rubyonrails.org/2009/2/27/this-week-in-edge-rails"&gt;usual channels&lt;/a&gt;, I thought I&amp;#8217;d document a couple of enhancements to the form option helpers here.&lt;/p&gt;
&lt;h2&gt;Disabled option tags&lt;/h2&gt;
&lt;p&gt;The form option helpers have been updated so that you can now specify disabled option tags:&lt;/p&gt;
&lt;div class="small_code"&gt;
&lt;p&gt;81444&lt;/p&gt;
&lt;p&gt;&lt;/div&gt;&lt;div class="small_code_bottom"&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Disabled option tags appear greyed out and cannot be selected by the user (or at least they do in &lt;em&gt;normal browsers&lt;/em&gt; &amp;#8211; see below).&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/06032009/select-with-disabled-option-tag.gif" title="Select tag with disabled option tags" alt="Select tag with disabled option tags" /&gt;&lt;/p&gt;
&lt;h2&gt;Lambdas for selecting and disabling option tags from collections&lt;/h2&gt;
&lt;p&gt;You can now use anonymous functions to specify which members of a collection should be selected or disabled in the resultant option tags. For example, you may want to disable product sizes that are out of stock:&lt;/p&gt;
&lt;div class="small_code"&gt;
&lt;p&gt;81456&lt;/p&gt;
&lt;p&gt;&lt;/div&gt;&lt;div class="small_code_bottom"&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;This works exactly the same for selecting values, simply pass your anonymous function in as :selected.&lt;/p&gt;
&lt;h2&gt;A word of caution &amp;#8211; always coding defensively&lt;/h2&gt;
&lt;p&gt;Although disabled option tags are part of the &lt;a href="http://www.w3.org/TR/html401/interact/forms.html#h-17.6"&gt;&lt;span class="caps"&gt;HTML&lt;/span&gt; specification&lt;/a&gt;, Internet Explorer 6 and 7 do not support them and will display disabled option tags as selectable. And although there are &lt;a href="http://apptaro.seesaa.net/article/21140090.html"&gt;hacks&lt;/a&gt; to get IE to behave, you can never guarantee that disabled values will not be submitted by someone constructing a html post. Therefor, it&amp;#8217;s always best to code defensively and guard against the potential selection of disabled values in your controller actions.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Disabled option tags in rails forms</title>
   <link href="http://tekin.co.uk/2009/01/05/disabled-option-tags-in-rails-forms.html"/>
   <updated>2009-01-05T00:00:00+00:00</updated>
   <id>http://tekin.co.uk/2009/01/05/disabled-option-tags-in-rails-forms</id>
   <content type="html">&lt;p&gt;&lt;em&gt;&lt;strong&gt;Update:&lt;/strong&gt; &lt;a href="http://github.com/rails/rails/commit/1525f3816e9b51d93d2e1356d1b90ba49213d325"&gt;My patch&lt;/a&gt; has now been accepted into core, which means that as of Rails 2.3, this plugin should no longer be necessary. More details &lt;a href="http://tekin.co.uk/2009/03/new-in-rails-23-disabled-option-tags-and-lambdas-for-selecting-and-disabling-options-from-collections"&gt;here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Ever wanted to disable options in a form select in rails? I have; it feels more useable to me to &lt;a href="http://www.w3schools.com/tags/att_option_disabled.asp"&gt;disable&lt;/a&gt; out of stock product sizes:&lt;/p&gt;
&lt;p&gt;&lt;img src="/images/02012009/disabled-option.gif" title="Select with a disabled option tag greyed out and not selectable" alt="Select with a disabled option tag greyed out and not selectable" /&gt;&lt;/p&gt;
&lt;p&gt;The rails Form Option Helpers won&amp;#8217;t let you do this as they currently stand. So until &lt;a href="http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/837"&gt;things change in core&lt;/a&gt;, I&amp;#8217;ve put together the &lt;a href="http://github.com/tekin/option_tags_will_disable/tree/master"&gt;option_tags_will_disable&lt;/a&gt; plugin.&lt;/p&gt;
&lt;p&gt;Simply specify the disabled values when calling options_for_select:&lt;/p&gt;
&lt;div class="small_code"&gt;
&lt;p&gt;81467&lt;/p&gt;
&lt;p&gt;&lt;/div&gt;&lt;div class="small_code_bottom"&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;You can do the same when working with collections, but more interestingly, you can also give a Proc to identify which elements should be disabled:&lt;/p&gt;
&lt;div class="small_code"&gt;
&lt;p&gt;81469&lt;/p&gt;
&lt;p&gt;&lt;/div&gt;&lt;div class="small_code_bottom"&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;And as an added bonus, selected options can also be identified with a Proc!&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Rails gets some engines love</title>
   <link href="http://tekin.co.uk/2008/11/26/rails-gets-some-engines-love.html"/>
   <updated>2008-11-26T00:00:00+00:00</updated>
   <id>http://tekin.co.uk/2008/11/26/rails-gets-some-engines-love</id>
   <content type="html">&lt;p&gt;No sooner is &lt;a href="http://guides.rubyonrails.org/2_2_release_notes.html"&gt;Rails 2.2 out the door&lt;/a&gt; than edge Rails gets exciting again!&lt;/p&gt;
&lt;p&gt;&lt;a href="github.com/rails/rails/commit/63d8f56774dcb1ea601928c3eb6c119d359fae10"&gt;A tasty little commit&lt;/a&gt; hints at some major changes to the way Rails handles plugins. Finally, the awesome features of the &lt;a href="http://github.com/lazyatom/engines/tree/master"&gt;engines&lt;/a&gt; plugin (lovingly crafted by &lt;a href="http://interblah.net/"&gt;James Adams&lt;/a&gt;) will be creeping into core.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m not one to speculate what brought about the &lt;a href="http://weblog.rubyonrails.org/2005/11/11/why-engines-and-components-are-not-evil-but-distracting"&gt;change in heart&lt;/a&gt;, I&amp;#8217;m just glad Rails is finally drinking the engines Kool-Aid!&lt;/p&gt;
&lt;h2&gt;Engines? Wha?&lt;/h2&gt;
&lt;p&gt;As it says in the &lt;a href="http://github.com/lazyatom/engines/tree/master/README"&gt;&lt;span class="caps"&gt;README&lt;/span&gt;&lt;/a&gt;: &amp;#8220;The engines plugin enhances Rails&amp;#8217; own plugin framework, making it simple to share controllers, helpers, models, public, assets, routes and migrations in plugins&amp;#8221;.&lt;/p&gt;
&lt;p&gt;In a nutshell, you get to create slices of apps as plugins which makes it a piece of cake to to share common functionality between multiple applications. In my case, I&amp;#8217;ve been able to put together several e-commerce websites with practically all the core functionality provided by a set of plugins. The beauty of it is, you can easily override views, actions, etc, in your app to make each site it&amp;#8217;s own. And when you fix a bug, or add a new feature, all the sites can benefit!&lt;/p&gt;
&lt;h2&gt;What comes next?&lt;/h2&gt;
&lt;p&gt;It&amp;#8217;s still early days and it&amp;#8217;s not yet clear just how much of this is getting rolled into Rails, but James has &lt;a href="http://www.ruby-forum.com/topic/171872#753531"&gt;hinted&lt;/a&gt; that much will make it across, including migrations, routes and asset management.&lt;/p&gt;
&lt;p&gt;In the mean time, if you want to see what all the fuss is about, check out &lt;a href="http://github.com/lazyatom/engines/tree/master"&gt;the engines plugin&lt;/a&gt; which, thanks to the hard work of everyone involved, now runs happily on Rails 2.2!&lt;/p&gt;
&lt;h2&gt;Update&lt;/h2&gt;
&lt;p&gt;The &lt;a href="http://github.com/rails/rails/commit/40b40c487040d9c721d486e8ec8cfbc53a8cd79a"&gt;commits&lt;/a&gt; are &lt;a href="http://github.com/rails/rails/commit/4999d52e08a02ebba344f6c318f0af4b5b18f0e5"&gt;coming&lt;/a&gt; thick and fast now. I&amp;#8217;m certainly looking forward to road testing these new feature as they take shape.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Rails and git submodules can play nice</title>
   <link href="http://tekin.co.uk/2008/08/11/rails-and-git-submodules-can-play-nice.html"/>
   <updated>2008-08-11T00:00:00+01:00</updated>
   <id>http://tekin.co.uk/2008/08/11/rails-and-git-submodules-can-play-nice</id>
   <content type="html">&lt;p&gt;I use git submodules to track plugins that I have under active development. This way, I can make changes to the main repository as well as the plugins with minimum fuss. There&amp;#8217;s &lt;a href="http://git.or.cz/gitwiki/GitSubmoduleTutorial"&gt;a great tutorial on working with submodules&lt;/a&gt;, which includes a couple of gotchas that may explain why submodules have got such a bad rep from some quarters.&lt;/p&gt;
&lt;h2&gt;Gotcha No. 1 &amp;#8211; Always commit changes in your submodules before commiting your main repository&lt;/h2&gt;
&lt;p&gt;If you make any changes to a submodule, be sure to commit and publish these changes &lt;strong&gt;before&lt;/strong&gt; you commit anything in the main repository, otherwise you and others will have issues trying to clone the repository.&lt;/p&gt;
&lt;h2&gt;Gotcha No 2 &amp;#8211; Check you&amp;#8217;re on a branch before making changes&lt;/h2&gt;
&lt;p&gt;If you are cloning a repo with a submodule and run git submodule init/update, be aware that the submodule has been checked out at a specific commit as apposed to the head of a branch meaning you have to checkout a branch before you make any changes.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Passenger/mod_rails 2.0 RC1</title>
   <link href="http://tekin.co.uk/2008/06/12/passenger-mod_rails-2-0-rc1.html"/>
   <updated>2008-06-12T00:00:00+01:00</updated>
   <id>http://tekin.co.uk/2008/06/12/passenger-mod_rails-2-0-rc1</id>
   <content type="html">&lt;p&gt;The guys at &lt;a href="http://blog.phusion.nl"&gt;Phusion&lt;/a&gt; have been hard at work improving mod_rails and a &lt;a href="http://blog.phusion.nl/2008/06/09/phusion-passenger-20-rc-1-and-ruby-enterprise-edition-released"&gt;release candidate&lt;/a&gt; for 2.0 is now available. This includes: rack support; faster graceful restarts; less memory usage; fair load balancing; upload buffering; better stability and much more. Upgrade now for an instant win!&lt;/p&gt;
&lt;p&gt;Update: if you have problems installing from the gem, get the &lt;a href="http://github.com/FooBarWidget/passenger/tree/master"&gt;latest version from github&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>mod_rails and apache on OS X Leopard</title>
   <link href="http://tekin.co.uk/2008/06/02/mod_rails-and-apache-on-os-x-leopard.html"/>
   <updated>2008-06-02T00:00:00+01:00</updated>
   <id>http://tekin.co.uk/2008/06/02/mod_rails-and-apache-on-os-x-leopard</id>
   <content type="html">&lt;p&gt;I was going to write up my experience rolling mod_rails on the default install of Apache to tidy up my development environment, but someone &lt;a href="http://napkin.highgroove.com/articles/2008/05/27/development-with-rails-passenger-aka-mod_rails-on-mac"&gt;beat me to it&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;There&amp;#8217;s only one thing I did differently &amp;#8211; I like to keep my apps in the Sites folder to keep things tidy &amp;#8211; so in the spirit of keeping things &lt;span class="caps"&gt;DRY&lt;/span&gt; I won&amp;#8217;t duplicate an already &lt;a href="http://napkin.highgroove.com/articles/2008/05/27/development-with-rails-passenger-aka-mod_rails-on-mac"&gt;good write-up&lt;/a&gt;, but I will add a couple of points that caught me out.&lt;/p&gt;
&lt;h2&gt;Apache 2 and NameVirtualHost&lt;/h2&gt;
&lt;p&gt;If you find that Apache will only serve up the first of your virtual hosts, check you&amp;#8217;ve &lt;a href="http://alexking.org/blog/2007/11/01/apache-2-only-serves-first-virtual-host"&gt;correctly specified the NameVirtualHost directive&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;Beware, FileVault and permissions&lt;/h2&gt;
&lt;p&gt;If you&amp;#8217;re running FileVault, you might have a &lt;a href="http://blog.phpguy.org/2008/04/26/apple-filevault-and-apache-http-server"&gt;bit of fiddling to do with your file permissions&lt;/a&gt;.&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>Rails plugins and the move to gems</title>
   <link href="http://tekin.co.uk/2008/05/31/rails-plugins-and-the-move-to-gems.html"/>
   <updated>2008-05-31T00:00:00+01:00</updated>
   <id>http://tekin.co.uk/2008/05/31/rails-plugins-and-the-move-to-gems</id>
   <content type="html">&lt;p&gt;This week, I made my first &lt;a href="http://github.com/rails/rails/commit/1b0654ea41d15552c19f767570d4f551d617e742"&gt;contribution to core&lt;/a&gt; which made installing plugins from git repositories over ssh work. It was a pretty small, mangy little patch &amp;#8211; nothing more than fixing a typo in the end &amp;#8211; but it felt good giving something back to a framework that has given me so much.&lt;/p&gt;
&lt;p&gt;Now that I&amp;#8217;m newly freelance, I&amp;#8217;m hoping to be able to spend more time giving back to the Rails ecosystem, and the first port of call might have to be the plugin management system. I know plugins are becoming decidedly unfashionable with a lot of &lt;a href="http://blog.jayfields.com/2006/12/rails-plugins-why.html"&gt;smart people saying&lt;/a&gt; they you should be &lt;a href="http://nubyonrails.com/articles/tutorial-publishing-rubygems-with-hoe"&gt;using gems instead&lt;/a&gt;. And with the &lt;a href="http://github.com/rails/rails/commit/088ef182e3006294b8f0e9b185d272a777c4437a"&gt;recent additions&lt;/a&gt; to rails this makes even more sense and you really should be removing those plugins from your apps in favour of loading them as gem dependencies. But in some scenarios, a plugin is all that will do.&lt;/p&gt;
&lt;p&gt;In my case, I make use of the &lt;a href="http://rails-engines.org"&gt;engines plugin&lt;/a&gt; (another unfashionable and often misunderstood bit of rails goodness) to share common application structure between a few apps, and here the whole plugin-as-gem thing just doesn&amp;#8217;t fit.&lt;/p&gt;
&lt;p&gt;Having been underwhelmed with the Piston equivalents for git, I&amp;#8217;ve found myself using ./script/plugin install again, and although this now works with git repositories, ./script/plugin update doesn&amp;#8217;t. Can it be that hard? Time to find out&amp;#8230;&lt;/p&gt;</content>
 </entry>
 
 <entry>
   <title>My blog is born</title>
   <link href="http://tekin.co.uk/2008/05/27/my-blog-is-born.html"/>
   <updated>2008-05-27T00:00:00+01:00</updated>
   <id>http://tekin.co.uk/2008/05/27/my-blog-is-born</id>
   <content type="html">&lt;p&gt;Finally after much twiddling with WordPress themes (so glad I don’t work with php anymore) here is my new blog! Because every freelance Rails developer worth his salt needs a blog, right!?&lt;/p&gt;
&lt;p&gt;Thanks to &lt;a href="http://www.sofiski.com"&gt;Sophie&lt;/a&gt; for the great design. Now all I need is some actual content…&lt;/p&gt;</content>
 </entry>
 
 
</feed>