<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>This Entangled Bank: Category Ruby on Rails</title>
    <link>http://entangledbank.co.uk/articles/category/ruby-on-rails</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>may contain traces of knowledge</description>
    <item>
      <title>editing ActiveRecord collection with related drop-downs using related_select_forms</title>
      <description>&lt;p&gt;Another problem setting the &lt;span class="caps"&gt;HTML&lt;/span&gt; &lt;code&gt;name&lt;/code&gt; attribute when editing a collection of ActiveRecord objects in a Rails application. This time I was using the &lt;code&gt;related_select_forms&lt;/code&gt; plugin to build related drop-down (select) lists. The plugin which creates all the necessary javascript to dynamically reload the second list according to the selection in the first list is kindly provided by Dimitrij Denissenko and available &lt;a href="http://dvisionfactory.googlecode.com/svn/rails/plugins/related_select_forms/"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;After a bit of research I found that the &lt;code&gt;name&lt;/code&gt; argument can be arbitrarily defined in the &lt;code&gt;html_options&lt;/code&gt; hash passed as the final argument to the select list helper (see the docs &lt;a href="http://www.railshelp.com/ActionView::Helpers::FormOptionsHelper"&gt;here&lt;/a&gt;).&lt;/p&gt;


	&lt;p&gt;First I had to build up the &lt;code&gt;name&lt;/code&gt; strings for the html in the format: &lt;/p&gt;


	&lt;pre&gt;&lt;code&gt;product[1424][field_name]&lt;/code&gt;&lt;/pre&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;theme_name = &amp;quot;product[&amp;quot; + @product.id.to_s + &amp;quot;][theme_id]&amp;quot; 
sub_theme_name = &amp;quot;product[&amp;quot; + @product.id.to_s + &amp;quot;][sub_theme_id]&amp;quot;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;strong&gt;first select list&lt;/strong&gt;
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;%= select(:theme, :id, theme_list, {},
            { :name =&amp;gt; theme_name } ) %&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;&lt;strong&gt;second select list&lt;/strong&gt;
 &lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;                    
&amp;lt;%= related_collection_select(
       :sub_theme, :id, [:theme, :id],  SubTheme.live_list, 
       :id, :name, :theme_id, 
       {}, 
       { :name =&amp;gt; sub_theme_name } ) %&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;


	&lt;p&gt;NB: there is a slight gotcha here with the hashes. The first (empty) hash is the &lt;code&gt;options{} &lt;/code&gt;hash used only for &lt;code&gt;{:include_blank =&amp;gt; true}&lt;/code&gt;, the second hash is used to set whatever &lt;span class="caps"&gt;HTML&lt;/span&gt; attributes you need, eg: &lt;code&gt;{ :selected =&amp;gt; @product.sub_theme_id, :multiple =&amp;gt; true, :name =&amp;gt; sub_name }&lt;/code&gt;. You &lt;strong&gt;must&lt;/strong&gt; include the first hash, empty if you don&amp;#8217;t want to use &lt;code&gt;:include_blank =&amp;gt; true&lt;/code&gt;.&lt;/p&gt;</description>
      <pubDate>Tue, 11 Sep 2007 10:13:00 +0100</pubDate>
      <guid isPermaLink="false">urn:uuid:7fc8e690-e059-40cb-806e-d8b8caf4f2e9</guid>
      <author>Ed</author>
      <link>http://entangledbank.co.uk/articles/2007/09/11/editing-activerecord-collection-with-related_select_forms</link>
      <category>Ruby on Rails</category>
      <category>rails</category>
    </item>
    <item>
      <title>multiple cygwin terminals without running X</title>
      <description>I found &lt;a href="http://en.poderosa.org/"&gt;Poderosa&lt;/a&gt; to be a good solution for running multiple Cygwin terminals within a tabbed window whilst doing Rails development.  &lt;p&gt;
&lt;div style="" class="lightboxplugin"&gt;&lt;a href="/files/poderosa-big.gif" rel="lightbox" title=""&gt;&lt;img src="/files/poderosa-small.gif" alt="" title=""/&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;
As Poderosa is a Windows app it was easier to set up than  the various X Window solutions suggested, such as &lt;span class="caps"&gt;MRXVT&lt;/span&gt;. 

	&lt;p&gt;You can split the screen if you like which I do when I need to keep an eye on both my development and test log files.&lt;/p&gt;</description>
      <pubDate>Thu, 01 Mar 2007 00:08:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:2a784e15-e45e-4a2d-baf3-4b314258f300</guid>
      <author>Ed</author>
      <link>http://entangledbank.co.uk/articles/2007/03/01/multiple-cygwin-terminals-without-running-x</link>
      <category>Ruby on Rails</category>
      <category>rails</category>
    </item>
    <item>
      <title>Webrick on XP: starts OK then hangs on first request?</title>
      <description>&lt;p&gt;I had this problem and found the solution:&lt;/p&gt;

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;netsh&lt;/span&gt; &lt;span class="ident"&gt;winsock&lt;/span&gt; &lt;span class="ident"&gt;reset&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;here: &lt;a href="http://www.db75.com/new_blog/?p=249"&gt;http://www.db75.com/new_blog/?p=249&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If anyone knows how to get XP to un-confuse itself without requiring a reboot, then it would be good to know.&lt;/p&gt;</description>
      <pubDate>Tue, 30 Jan 2007 00:09:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:b29f0f04-08a0-47ff-9379-7c93ef7a0867</guid>
      <author>Ed</author>
      <link>http://entangledbank.co.uk/articles/2007/01/30/webrick-on-xp-starts-ok-then-hangs-on-first-request</link>
      <category>Ruby on Rails</category>
      <category>rails</category>
      <category>computers</category>
    </item>
  </channel>
</rss>
