<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>This Entangled Bank: Tag rails</title>
  <subtitle type="html">may contain traces of knowledge</subtitle>
  <id>tag:entangledbank.co.uk,2005:Typo</id>
  <generator version="4.0" uri="http://www.typosphere.org">Typo</generator>
  <link href="http://entangledbank.co.uk/xml/atom/tag/rails/feed.xml" rel="self" type="application/atom+xml"/>
  <link href="http://entangledbank.co.uk/articles/tag/rails?tag=rails" rel="alternate" type="text/html"/>
  <updated>2007-09-11T11:07:28+01:00</updated>
  <entry>
    <author>
      <name>Ed</name>
    </author>
    <id>urn:uuid:7fc8e690-e059-40cb-806e-d8b8caf4f2e9</id>
    <published>2007-09-11T10:13:00+01:00</published>
    <updated>2007-09-11T11:07:28+01:00</updated>
    <title type="html">editing ActiveRecord collection with related drop-downs using related_select_forms</title>
    <link href="http://entangledbank.co.uk/articles/2007/09/11/editing-activerecord-collection-with-related_select_forms" rel="alternate" type="text/html"/>
    <category term="ruby-on-rails" scheme="http://entangledbank.co.uk/articles/category/ruby-on-rails" label="Ruby on Rails"/>
    <category term="rails" scheme="http://entangledbank.co.uk/articles/tag/rails"/>
    <summary type="html">&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;</summary>
    <content type="html">&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;</content>
  </entry>
  <entry>
    <author>
      <name>Ed</name>
    </author>
    <id>urn:uuid:cf6795c2-b665-4aac-8ce9-921257974661</id>
    <published>2007-05-09T00:38:00+01:00</published>
    <updated>2007-05-10T01:07:15+01:00</updated>
    <title type="html">use multiple instances of FCK Editor when editing a Rails collection</title>
    <link href="http://entangledbank.co.uk/articles/2007/05/09/use-multiple-instances-of-fck-editor-when-editing-a-rails-collection" rel="alternate" type="text/html"/>
    <category term="rails" scheme="http://entangledbank.co.uk/articles/tag/rails"/>
    <summary type="html">&lt;p&gt;Scott Rutherford has kindly packaged up a Rails helper for the &lt;span class="caps"&gt;FCK&lt;/span&gt; Editor as a plugin. You can find it &lt;a href="http://blog.caronsoftware.com/articles/category/fckeditor-plugin"&gt;here&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;I was stumped for a while as I wanted to use multiple instances of the editor in a form used to edit a collection of objects, but figured it out with a little help from Scott.&lt;/p&gt;</summary>
    <content type="html">&lt;p&gt;Scott Rutherford has kindly packaged up a Rails helper for the &lt;span class="caps"&gt;FCK&lt;/span&gt; Editor as a plugin. You can find it &lt;a href="http://blog.caronsoftware.com/articles/category/fckeditor-plugin"&gt;here&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;I was stumped for a while as I wanted to use multiple instances of the editor in a form used to edit a collection of objects, but figured it out with a little help from Scott.&lt;/p&gt;&lt;p&gt;I was using the syntax:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;%= text_field(&amp;quot;product[]&amp;quot;, &amp;quot;name&amp;quot;, :size =&amp;gt; 60) %&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

successfully on other fields but trying:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;%= fckeditor_textarea(&amp;quot;product[]&amp;quot;, 'description', ... %&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;gave me the error:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;(eval):1:in `[]': wrong number of arguments (0 for 1)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

In order to get &lt;span class="caps"&gt;HTML&lt;/span&gt; in the correct form:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;textarea id='product_3893_description_editor' 
 name='product[3893][description]'&amp;gt;blank&amp;lt;/textarea&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

it was necessary to pass the product ID to Scott&amp;#8217;s helper as an additional argument:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;&amp;lt;%= fckeditor_textarea_multi( &amp;quot;product&amp;quot;,  &amp;quot;description&amp;quot;, 
@product.id, { ...}) %&amp;gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

and tweak the helper in fckeditor.rb:
&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;fckeditor_textarea_multi&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;object&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;field&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;new_arg&lt;/span&gt;&lt;span class="punct"&gt;,&lt;/span&gt; &lt;span class="ident"&gt;options&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;{})&lt;/span&gt;
   &lt;span class="punct"&gt;...&lt;/span&gt; &lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="ident"&gt;snip&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;...&lt;/span&gt;  
   &lt;span class="ident"&gt;inputs&lt;/span&gt; &lt;span class="punct"&gt;=&lt;/span&gt; &lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;&lt;span class="string"&gt;&amp;lt;textarea id='&lt;span class="expr"&gt;#{id}&lt;/span&gt;' &lt;span class="expr"&gt;#{cols}&lt;/span&gt; &lt;span class="expr"&gt;#{rows}&lt;/span&gt;  
   name='&lt;span class="expr"&gt;#{object}&lt;/span&gt;[&lt;span class="expr"&gt;#{new_arg}&lt;/span&gt;][&lt;span class="expr"&gt;#{field}&lt;/span&gt;]'&amp;gt;
   &lt;span class="expr"&gt;#{value}&lt;/span&gt;&amp;lt;/textarea&amp;gt;&lt;span class="escape"&gt;\n&lt;/span&gt;&lt;/span&gt;&lt;span class="punct"&gt;&amp;quot;&lt;/span&gt;
   &lt;span class="punct"&gt;...&lt;/span&gt; &lt;span class="punct"&gt;[&lt;/span&gt;&lt;span class="ident"&gt;snip&lt;/span&gt;&lt;span class="punct"&gt;]&lt;/span&gt; &lt;span class="punct"&gt;...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content>
  </entry>
  <entry>
    <author>
      <name>Ed</name>
    </author>
    <id>urn:uuid:2a784e15-e45e-4a2d-baf3-4b314258f300</id>
    <published>2007-03-01T00:08:00+00:00</published>
    <updated>2007-03-01T00:27:01+00:00</updated>
    <title type="html">multiple cygwin terminals without running X</title>
    <link href="http://entangledbank.co.uk/articles/2007/03/01/multiple-cygwin-terminals-without-running-x" rel="alternate" type="text/html"/>
    <category term="ruby-on-rails" scheme="http://entangledbank.co.uk/articles/category/ruby-on-rails" label="Ruby on Rails"/>
    <category term="rails" scheme="http://entangledbank.co.uk/articles/tag/rails"/>
    <summary type="html">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;</summary>
    <content type="html">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;</content>
  </entry>
  <entry>
    <author>
      <name>Ed</name>
    </author>
    <id>urn:uuid:b29f0f04-08a0-47ff-9379-7c93ef7a0867</id>
    <published>2007-01-30T00:09:00+00:00</published>
    <updated>2007-02-04T08:30:29+00:00</updated>
    <title type="html">Webrick on XP: starts OK then hangs on first request?</title>
    <link href="http://entangledbank.co.uk/articles/2007/01/30/webrick-on-xp-starts-ok-then-hangs-on-first-request" rel="alternate" type="text/html"/>
    <category term="ruby-on-rails" scheme="http://entangledbank.co.uk/articles/category/ruby-on-rails" label="Ruby on Rails"/>
    <category term="rails" scheme="http://entangledbank.co.uk/articles/tag/rails"/>
    <category term="computers" scheme="http://entangledbank.co.uk/articles/tag/computers"/>
    <summary type="html">&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;</summary>
    <content type="html">&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;</content>
  </entry>
</feed>
