<?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>Alastair&#039;s Axioms &#187; Ruby</title>
	<atom:link href="http://blog.alastairdawson.com/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.alastairdawson.com</link>
	<description>Flex, Ruby, etc. etc.</description>
	<lastBuildDate>Thu, 11 Feb 2010 19:28:16 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Automate font compiling for Flex with Ruby</title>
		<link>http://blog.alastairdawson.com/2009/06/30/automate-font-compiling-for-flex-with-ruby/</link>
		<comments>http://blog.alastairdawson.com/2009/06/30/automate-font-compiling-for-flex-with-ruby/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 17:31:24 +0000</pubDate>
		<dc:creator>Alastair</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.alastairdawson.com/?p=171</guid>
		<description><![CDATA[I came up with this solution when I had to compile over 100 fonts into SWF files for a recent project. Doing this by hand would have been madness so I wrote a ruby script and a shell script to automate the process.
Step 1: Setup
The directory structure I used was as follows.
convert.rb (the ruby script)
compile.sh [...]]]></description>
			<content:encoded><![CDATA[<p>I came up with this solution when I had to compile over 100 fonts into SWF files for a recent project. Doing this by hand would have been madness so I wrote a ruby script and a shell script to automate the process.</p>
<p><strong>Step 1: Setup</strong></p>
<p>The directory structure I used was as follows.</p>
<pre class="textmate-source"><span class="text text_plain"><span class="meta meta_paragraph meta_paragraph_text">convert.rb (the ruby script)
compile.sh (the shell script)
fonts/ (a directory for font files - .ttf and .otf)
as/ (a directory for the generated ActionScript)
swfs/ (a directory for the compiled swf files)</span></span></pre>
<p><strong>Step 2: Prep fonts</strong></p>
<p>Ok told a tiny white lie when I said it was all automated. Since (to my knowledge) you can&#8217;t inspect a font file to determine if it&#8217;s normal, regular, bold, italic, or bold italic (the weights and styles Flex understands) you&#8217;ll have to set up a naming convention that the Ruby script can parse. You&#8217;ll be using the font name to create an ActionScript class so it should also be a legal name. </p>
<p>Here&#8217;s an example using the Arial family.</p>
<pre class="textmate-source"><span class="text text_plain"><span class="meta meta_paragraph meta_paragraph_text">Arial.ttf (regular fontWeight and normal fontStyle)
Arial_Italic.ttf (regular fontWeight and italic fontStyle)
Arial_Bold.ttf (bold fontWeight and normal fontStyle)
Arial_BoldItalic.ttf (bold fontWeight and italic fontStyle)</span></span></pre>
<p><strong>Step 3: The Ruby Script</strong></p>
<pre class="textmate-source"><span class="source source_ruby"><span class="meta meta_require meta_require_ruby"><span class="keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby">require</span> <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>find<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span></span>

<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> delete any previous as
</span><span class="support support_class support_class_ruby">Find</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>find<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span> <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>as<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span> <span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do </span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span> <span class="variable variable_other variable_other_block variable_other_block_ruby">as</span> <span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span>
  <span class="keyword keyword_control keyword_control_ruby">if</span> <span class="support support_class support_class_ruby">File</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>extname<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span> as <span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby">==</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>.as<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
    <span class="support support_class support_class_ruby">File</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>unlink as
  <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class="keyword keyword_control keyword_control_ruby">end</span>

<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby"><span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> generate new as
</span><span class="support support_class support_class_ruby">Find</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>find<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span> <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>fonts<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span> <span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do </span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span> <span class="variable variable_other variable_other_block variable_other_block_ruby">font</span> <span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span>
  <span class="keyword keyword_control keyword_control_ruby">if</span> <span class="support support_class support_class_ruby">File</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>file?<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span> font <span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">    <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> extension name
</span>    ext <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="support support_class support_class_ruby">File</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>extname<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span> font <span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">    <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> is font
</span>    <span class="keyword keyword_control keyword_control_ruby">if</span> ext <span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby">==</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>.ttf<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span> <span class="keyword keyword_operator keyword_operator_logical keyword_operator_logical_ruby">||</span> ext <span class="keyword keyword_operator keyword_operator_comparison keyword_operator_comparison_ruby">==</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>.otf<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">      <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> file name
</span>      full_name <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="support support_class support_class_ruby">File</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>basename<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span> font <span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      name <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="support support_class support_class_ruby">File</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>basename<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span> font<span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> ext <span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">      <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> font weight and style
</span>      font_weight <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
      font_style <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
      <span class="keyword keyword_control keyword_control_ruby">if</span> full_name<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>include? <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>_Bold<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span> <span class="keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby">+</span> ext
        font_weight <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>fontWeight='bold',<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
      <span class="keyword keyword_control keyword_control_ruby">end</span>
      <span class="keyword keyword_control keyword_control_ruby">if</span> full_name<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>include? <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>_Italic<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span> <span class="keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby">+</span> ext
        font_style <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>fontStyle='italic',<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
      <span class="keyword keyword_control keyword_control_ruby">end</span>
      <span class="keyword keyword_control keyword_control_ruby">if</span> full_name<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>include? <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>_BoldItalic<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span> <span class="keyword keyword_operator keyword_operator_arithmetic keyword_operator_arithmetic_ruby">+</span> ext
        font_weight <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>fontWeight='bold',<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
        font_style <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>fontStyle='italic',<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
      <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">      <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> generate as
</span>      f <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="support support_class support_class_ruby">File</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span><span class="keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby">new</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>as/<span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>name<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span>.as<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span>  <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>w+<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
      f<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>write <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>package
      {
        import flash.display.Sprite;

        public class <span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>name<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span> extends Sprite
        {
          [Embed(source='../fonts/<span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>full_name<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span>', fontName='<span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>name<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span>', <span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>font_weight<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span> <span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>font_style<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span> unicodeRange='U+0000-U+00FF,U+2100-U+214F')]
          public var Font:Class;
        }
      }<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby">      <span class="punctuation punctuation_definition punctuation_definition_comment punctuation_definition_comment_ruby">#</span> some helpful output
</span>      print <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>,"<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span><span class="source source_ruby source_ruby_embedded source_ruby_embedded_source"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">#{</span>name<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">}</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>"<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span>
    <span class="keyword keyword_control keyword_control_ruby">end</span>
  <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>In TextMate you can open this script and hit Command-R to run it, or run it via the command line &#8216;ruby convert.rb&#8217;. Once the script runs you&#8217;ll have generated ActionScript files in the &#8216;as&#8217; directory ready to be compiled.</p>
<p><strong>Step 4: The Shell Script</strong></p>
<pre class="textmate-source"><span class="source source_shell"><span class="support support_function support_function_builtin support_function_builtin_shell">echo</span> <span class="string string_quoted string_quoted_double string_quoted_double_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">"</span>&lt;h2&gt;Fonts Custom Compile&lt;/h2&gt;<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">"</span></span><span class="keyword keyword_operator keyword_operator_list keyword_operator_list_shell">;</span>
<span class="support support_function support_function_builtin support_function_builtin_shell">echo</span> <span class="string string_quoted string_quoted_double string_quoted_double_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">"</span>&lt;code&gt; Started @ <span class="string string_interpolated string_interpolated_backtick string_interpolated_backtick_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">`</span>date <span class="string string_quoted string_quoted_double string_quoted_double_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">"</span>+%H:%M:%S<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">"</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">`</span></span>&lt;/code&gt;&lt;br /&gt;<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">"</span></span><span class="keyword keyword_operator keyword_operator_list keyword_operator_list_shell">;</span>

<span class="meta meta_scope meta_scope_for-in-loop meta_scope_for-in-loop_shell"><span class="keyword keyword_control keyword_control_shell">for</span> <span class="variable variable_other variable_other_loop variable_other_loop_shell">i</span> <span class="keyword keyword_control keyword_control_shell">in</span> <span class="string string_interpolated string_interpolated_backtick string_interpolated_backtick_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">`</span><span class="support support_function support_function_builtin support_function_builtin_shell">cd</span> as/<span class="keyword keyword_operator keyword_operator_list keyword_operator_list_shell">;</span> ls <span class="keyword keyword_operator keyword_operator_glob keyword_operator_glob_shell">*</span>.as<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">`</span></span><span class="keyword keyword_operator keyword_operator_list keyword_operator_list_shell">;</span> <span class="keyword keyword_control keyword_control_shell">do</span>
  swf=<span class="string string_interpolated string_interpolated_backtick string_interpolated_backtick_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">`</span><span class="support support_function support_function_builtin support_function_builtin_shell">echo</span> <span class="variable variable_other variable_other_normal variable_other_normal_shell"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_shell">$</span>i</span> <span class="keyword keyword_operator keyword_operator_pipe keyword_operator_pipe_shell">|</span>  awk -F. <span class="string string_quoted string_quoted_single string_quoted_single_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">'</span>{print $1}<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">'</span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">`</span></span>
  swf=<span class="string string_quoted string_quoted_double string_quoted_double_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">"</span><span class="variable variable_other variable_other_normal variable_other_normal_shell"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_shell">$</span>swf</span>.swf<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">"</span></span>
  <span class="string string_quoted string_quoted_double string_quoted_double_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">"</span>/Applications/Adobe Flex Builder 3/sdks/3.3.0.4589/bin/mxmlc<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">"</span></span> -file-specs=<span class="string string_quoted string_quoted_double string_quoted_double_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">"</span>as/<span class="variable variable_other variable_other_normal variable_other_normal_shell"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_shell">$</span>i</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">"</span></span> -o=<span class="string string_quoted string_quoted_double string_quoted_double_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">"</span>swfs/<span class="variable variable_other variable_other_normal variable_other_normal_shell"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_shell">$</span>swf</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">"</span></span> -managers=<span class="string string_quoted string_quoted_double string_quoted_double_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">"</span>flash.fonts.AFEFontManager<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">"</span></span> <span class="keyword keyword_operator keyword_operator_redirect keyword_operator_redirect_shell">2&gt;&amp;1</span><span class="keyword keyword_operator keyword_operator_list keyword_operator_list_shell">;</span>
<span class="keyword keyword_control keyword_control_shell">done</span></span></span></pre>
<p>You&#8217;ll need to customize the script for your Flex SDK location, mine is at <span class="string string_quoted string_quoted_double string_quoted_double_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">&quot;</span>/Applications/Adobe Flex Builder 3/sdks/3.3.0.4589/bin/mxmlc<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">&quot;</span></span>. The hidden gem in there is <span class="meta meta_scope meta_scope_for-in-loop meta_scope_for-in-loop_shell">-managers=<span class="string string_quoted string_quoted_double string_quoted_double_shell"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_shell">&quot;</span>flash.fonts.AFEFontManager<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_shell">&quot;</span></span></span>, about 90% of fonts will compile without it but the rest were blowing up until I added that argument.</p>
<p>Again with TextMate you can run the script with Command-R. Each font will take about five seconds to compile, my set of over 100 fonts took over ten minutes <img src='http://blog.alastairdawson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>That&#8217;s it! The SWFs are compiled and ready to be runtime loaded into a Flex app. Creating the ActionScript for 100+ fonts would have been a multi-day process but with a little scripting it took less than an hour.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alastairdawson.com/2009/06/30/automate-font-compiling-for-flex-with-ruby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Display Rails associations in a Flex DataGridColumn</title>
		<link>http://blog.alastairdawson.com/2008/06/29/display-rails-associations-in-a-flex-datagridcolumn/</link>
		<comments>http://blog.alastairdawson.com/2008/06/29/display-rails-associations-in-a-flex-datagridcolumn/#comments</comments>
		<pubDate>Sun, 29 Jun 2008 18:17:54 +0000</pubDate>
		<dc:creator>Alastair</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://blog.vixiom.com/2008/06/29/display-rails-associations-in-a-flex-datagridcolumn/</guid>
		<description><![CDATA[Frameworks like Ruby on Rails and CakePHP make it easy to set up model associations with belongs_to, has_many, and the ever popular has_and_belongs_to_many. However, getting those associations to show up in a Flex DataGridColumn&#8217;s dataField isn&#8217;t immediately obvious, you&#8217;d assume you could just do parent.child or child.parent but that just gives a blank column. After [...]]]></description>
			<content:encoded><![CDATA[<p>Frameworks like Ruby on Rails and CakePHP make it easy to set up model associations with belongs_to, has_many, and the ever popular has_and_belongs_to_many. However, getting those associations to show up in a Flex DataGridColumn&#8217;s dataField isn&#8217;t immediately obvious, you&#8217;d assume you could just do parent.child or child.parent but that just gives a blank column. After some digging I found the answer is to use a labelFunction.</p>
<p>In the example below there are two models in Rails, &#8216;Group&#8217; and &#8216;Category&#8217;, Group has_many Categories and Category belongs_to Group. Here&#8217;s the Flex code for the Categories DataGrid, groupName is the labelFunction that spits out a Category&#8217;s Group name (equivalent to @category.group.name in ruby):</p>
<pre class="textmate-source"><span class="text text_xml text_xml_mxml"><span class="meta meta_tag meta_tag_preprocessor meta_tag_preprocessor_xml"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml">&lt;?</span><span class="entity entity_name entity_name_tag entity_name_tag_xml">xml</span><span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_xml"> version</span>=<span class="string string_quoted string_quoted_double string_quoted_double_xml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_xml">&quot;</span>1.0<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_xml">&quot;</span></span><span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_xml"> encoding</span>=<span class="string string_quoted string_quoted_double string_quoted_double_xml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_xml">&quot;</span>utf-8<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_xml">&quot;</span></span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml">?&gt;</span></span>
<span class="meta meta_tag meta_tag_xml meta_tag_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_namespace entity_name_tag_namespace_xml entity_name_tag_namespace_xml_mxml">mx</span><span class="punctuation punctuation_separator punctuation_separator_namespace punctuation_separator_namespace_xml punctuation_separator_namespace_xml_mxml">:</span><span class="entity entity_name entity_name_tag entity_name_tag_localname entity_name_tag_localname_xml entity_name_tag_localname_xml_mxml">VBox</span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_namespace entity_other_attribute-name_namespace_xml entity_other_attribute-name_namespace_xml_mxml">xmlns</span>:<span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_localname entity_other_attribute-name_localname_xml entity_other_attribute-name_localname_xml_mxml">mx</span>=<span class="string string_quoted string_quoted_double string_quoted_double_xml string_quoted_double_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_xml punctuation_definition_string_begin_xml_mxml">&quot;</span>http://www.adobe.com/2006/mxml<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_xml punctuation_definition_string_end_xml_mxml">&quot;</span></span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_localname entity_other_attribute-name_localname_xml entity_other_attribute-name_localname_xml_mxml">width</span>=<span class="string string_quoted string_quoted_double string_quoted_double_xml string_quoted_double_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_xml punctuation_definition_string_begin_xml_mxml">&quot;</span>100%<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_xml punctuation_definition_string_end_xml_mxml">&quot;</span></span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_localname entity_other_attribute-name_localname_xml entity_other_attribute-name_localname_xml_mxml">height</span>=<span class="string string_quoted string_quoted_double string_quoted_double_xml string_quoted_double_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_xml punctuation_definition_string_begin_xml_mxml">&quot;</span>100%<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_xml punctuation_definition_string_end_xml_mxml">&quot;</span></span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&gt;</span></span>

    <span class="meta meta_tag meta_tag_xml meta_tag_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_namespace entity_name_tag_namespace_xml entity_name_tag_namespace_xml_mxml">mx</span><span class="punctuation punctuation_separator punctuation_separator_namespace punctuation_separator_namespace_xml punctuation_separator_namespace_xml_mxml">:</span><span class="entity entity_name entity_name_tag entity_name_tag_localname entity_name_tag_localname_xml entity_name_tag_localname_xml_mxml">Script</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&gt;</span></span>
        <span class="string string_unquoted string_unquoted_cdata string_unquoted_cdata_xml string_unquoted_cdata_xml_mxml punctuation string_unquoted_cdata_xml_mxml punctuation_definition string_unquoted_cdata_xml_mxml punctuation_definition_string string_unquoted_cdata_xml_mxml punctuation_definition_string_begin string_unquoted_cdata_xml_mxml punctuation_definition_string_begin_xml string_unquoted_cdata_xml_mxml punctuation_definition_string_begin_xml_mxml">&lt;![CDATA[</span><span class="source source_actionscript source_actionscript_3 source_actionscript_3_embedded source_actionscript_3_embedded_mxml">
            <span class="storage storage_type storage_type_import storage_type_import_actionscript storage_type_import_actionscript_3">import <span class="support support_class support_class_actionscript support_class_actionscript_3">mx.controls.dataGridClasses.DataGridColumn</span>;</span>

            <span class="storage storage_type storage_type_modifier storage_type_modifier_actionscript storage_type_modifier_actionscript_3">private <span class="storage storage_type storage_type_actionscript storage_type_actionscript_3">function</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_actionscript entity_name_type_class_actionscript_3">groupName</span></span>( <span class="support support_function support_function_properties support_function_properties_actionscript support_function_properties_actionscript_3">item</span><span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">:</span><span class="support support_class support_class_actionscript support_class_actionscript_3">Object</span>, column<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">:</span><span class="support support_class support_class_actionscript support_class_actionscript_3">DataGridColumn</span> )<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">:</span><span class="support support_class support_class_actionscript support_class_actionscript_3">String</span>
            {
                <span class="keyword keyword_control keyword_control_end keyword_control_end_actionscript keyword_control_end_actionscript_3">return</span> <span class="support support_function support_function_properties support_function_properties_actionscript support_function_properties_actionscript_3">item</span><span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">.</span>group<span class="keyword keyword_operator keyword_operator_symbolic keyword_operator_symbolic_actionscript keyword_operator_symbolic_actionscript_3">.</span><span class="support support_function support_function_actionscript support_function_actionscript_3">name</span>;
            }

        </span><span class="string string_unquoted string_unquoted_cdata string_unquoted_cdata_xml string_unquoted_cdata_xml_mxml punctuation string_unquoted_cdata_xml_mxml punctuation_definition string_unquoted_cdata_xml_mxml punctuation_definition_string string_unquoted_cdata_xml_mxml punctuation_definition_string_end string_unquoted_cdata_xml_mxml punctuation_definition_string_end_xml string_unquoted_cdata_xml_mxml punctuation_definition_string_end_xml_mxml">]]&gt;</span>
    <span class="meta meta_tag meta_tag_xml meta_tag_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_namespace entity_name_tag_namespace_xml entity_name_tag_namespace_xml_mxml">mx</span><span class="punctuation punctuation_separator punctuation_separator_namespace punctuation_separator_namespace_xml punctuation_separator_namespace_xml_mxml">:</span><span class="entity entity_name entity_name_tag entity_name_tag_localname entity_name_tag_localname_xml entity_name_tag_localname_xml_mxml">Script</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&gt;</span></span>

    <span class="meta meta_tag meta_tag_xml meta_tag_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_namespace entity_name_tag_namespace_xml entity_name_tag_namespace_xml_mxml">mx</span><span class="punctuation punctuation_separator punctuation_separator_namespace punctuation_separator_namespace_xml punctuation_separator_namespace_xml_mxml">:</span><span class="entity entity_name entity_name_tag entity_name_tag_localname entity_name_tag_localname_xml entity_name_tag_localname_xml_mxml">DataGrid</span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_localname entity_other_attribute-name_localname_xml entity_other_attribute-name_localname_xml_mxml">id</span>=<span class="string string_quoted string_quoted_double string_quoted_double_xml string_quoted_double_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_xml punctuation_definition_string_begin_xml_mxml">&quot;</span>dataGrid<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_xml punctuation_definition_string_end_xml_mxml">&quot;</span></span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_localname entity_other_attribute-name_localname_xml entity_other_attribute-name_localname_xml_mxml">width</span>=<span class="string string_quoted string_quoted_double string_quoted_double_xml string_quoted_double_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_xml punctuation_definition_string_begin_xml_mxml">&quot;</span>100%<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_xml punctuation_definition_string_end_xml_mxml">&quot;</span></span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_localname entity_other_attribute-name_localname_xml entity_other_attribute-name_localname_xml_mxml">height</span>=<span class="string string_quoted string_quoted_double string_quoted_double_xml string_quoted_double_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_xml punctuation_definition_string_begin_xml_mxml">&quot;</span>100%<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_xml punctuation_definition_string_end_xml_mxml">&quot;</span></span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&gt;</span></span>
        <span class="meta meta_tag meta_tag_xml meta_tag_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_namespace entity_name_tag_namespace_xml entity_name_tag_namespace_xml_mxml">mx</span><span class="punctuation punctuation_separator punctuation_separator_namespace punctuation_separator_namespace_xml punctuation_separator_namespace_xml_mxml">:</span><span class="entity entity_name entity_name_tag entity_name_tag_localname entity_name_tag_localname_xml entity_name_tag_localname_xml_mxml">columns</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&gt;</span></span>
            <span class="meta meta_tag meta_tag_xml meta_tag_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_namespace entity_name_tag_namespace_xml entity_name_tag_namespace_xml_mxml">mx</span><span class="punctuation punctuation_separator punctuation_separator_namespace punctuation_separator_namespace_xml punctuation_separator_namespace_xml_mxml">:</span><span class="entity entity_name entity_name_tag entity_name_tag_localname entity_name_tag_localname_xml entity_name_tag_localname_xml_mxml">DataGridColumn</span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_localname entity_other_attribute-name_localname_xml entity_other_attribute-name_localname_xml_mxml">headerText</span>=<span class="string string_quoted string_quoted_double string_quoted_double_xml string_quoted_double_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_xml punctuation_definition_string_begin_xml_mxml">&quot;</span>Name<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_xml punctuation_definition_string_end_xml_mxml">&quot;</span></span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_localname entity_other_attribute-name_localname_xml entity_other_attribute-name_localname_xml_mxml">dataField</span>=<span class="string string_quoted string_quoted_double string_quoted_double_xml string_quoted_double_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_xml punctuation_definition_string_begin_xml_mxml">&quot;</span>name<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_xml punctuation_definition_string_end_xml_mxml">&quot;</span></span> /<span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&gt;</span></span>
            <span class="meta meta_tag meta_tag_xml meta_tag_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_namespace entity_name_tag_namespace_xml entity_name_tag_namespace_xml_mxml">mx</span><span class="punctuation punctuation_separator punctuation_separator_namespace punctuation_separator_namespace_xml punctuation_separator_namespace_xml_mxml">:</span><span class="entity entity_name entity_name_tag entity_name_tag_localname entity_name_tag_localname_xml entity_name_tag_localname_xml_mxml">DataGridColumn</span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_localname entity_other_attribute-name_localname_xml entity_other_attribute-name_localname_xml_mxml">headerText</span>=<span class="string string_quoted string_quoted_double string_quoted_double_xml string_quoted_double_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_xml punctuation_definition_string_begin_xml_mxml">&quot;</span>Group<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_xml punctuation_definition_string_end_xml_mxml">&quot;</span></span> <span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_localname entity_other_attribute-name_localname_xml entity_other_attribute-name_localname_xml_mxml">labelFunction</span>=<span class="string string_quoted string_quoted_double string_quoted_double_xml string_quoted_double_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_xml punctuation_definition_string_begin_xml_mxml">&quot;</span>groupName<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_xml punctuation_definition_string_end_xml_mxml">&quot;</span></span> /<span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&gt;</span></span>
        <span class="meta meta_tag meta_tag_xml meta_tag_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_namespace entity_name_tag_namespace_xml entity_name_tag_namespace_xml_mxml">mx</span><span class="punctuation punctuation_separator punctuation_separator_namespace punctuation_separator_namespace_xml punctuation_separator_namespace_xml_mxml">:</span><span class="entity entity_name entity_name_tag entity_name_tag_localname entity_name_tag_localname_xml entity_name_tag_localname_xml_mxml">columns</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&gt;</span></span>
    <span class="meta meta_tag meta_tag_xml meta_tag_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_namespace entity_name_tag_namespace_xml entity_name_tag_namespace_xml_mxml">mx</span><span class="punctuation punctuation_separator punctuation_separator_namespace punctuation_separator_namespace_xml punctuation_separator_namespace_xml_mxml">:</span><span class="entity entity_name entity_name_tag entity_name_tag_localname entity_name_tag_localname_xml entity_name_tag_localname_xml_mxml">DataGrid</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&gt;</span></span>

<span class="meta meta_tag meta_tag_xml meta_tag_xml_mxml"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_namespace entity_name_tag_namespace_xml entity_name_tag_namespace_xml_mxml">mx</span><span class="punctuation punctuation_separator punctuation_separator_namespace punctuation_separator_namespace_xml punctuation_separator_namespace_xml_mxml">:</span><span class="entity entity_name entity_name_tag entity_name_tag_localname entity_name_tag_localname_xml entity_name_tag_localname_xml_mxml">VBox</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_xml punctuation_definition_tag_xml_mxml">&gt;</span></span></span></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.alastairdawson.com/2008/06/29/display-rails-associations-in-a-flex-datagridcolumn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run your web applications on Google&#8217;s infrastructure</title>
		<link>http://blog.alastairdawson.com/2008/04/07/run-your-web-applications-on-googles-infrastructure/</link>
		<comments>http://blog.alastairdawson.com/2008/04/07/run-your-web-applications-on-googles-infrastructure/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 07:01:53 +0000</pubDate>
		<dc:creator>Alastair</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.vixiom.com/2008/04/07/run-your-web-applications-on-googles-infrastructure/</guid>
		<description><![CDATA[Google releases App Engine. It&#8217;s Python only for now, but there are rumors more languages (Ruby!) will soon be available.
Here&#8217;s a video intro. And Django runs out of the box (in the box?) &#8211; well some parts are missing like no relational db &#8211; still you can&#8217;t beat the one line deployment!

Docs! Running Django on [...]]]></description>
			<content:encoded><![CDATA[<p>Google releases <a href="http://code.google.com/appengine/">App Engine</a>. It&#8217;s Python only for now, but there are rumors more languages (Ruby!) will soon be available.</p>
<p>Here&#8217;s a video intro. And Django runs out of the box (in the box?) &#8211; well some parts are missing like no relational db &#8211; still you can&#8217;t beat the one line deployment!</p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/bfgO-LXGpTM&#038;hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/bfgO-LXGpTM&#038;hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
<p>Docs! <a href="http://code.google.com/appengine/articles/django.html">Running Django on Google App Engine</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alastairdawson.com/2008/04/07/run-your-web-applications-on-googles-infrastructure/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PureMVC for Ruby</title>
		<link>http://blog.alastairdawson.com/2008/03/28/puremvc-for-ruby/</link>
		<comments>http://blog.alastairdawson.com/2008/03/28/puremvc-for-ruby/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 14:23:59 +0000</pubDate>
		<dc:creator>Alastair</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.vixiom.com/2008/03/28/puremvc-for-ruby/</guid>
		<description><![CDATA[The PureMVC framework is considered one of the best for Flash/Flex development (definitely the best documented), I hadn&#8217;t checked out the site in a while (which has undergone an overhaul and is much improved!) and since my last visit PureMVC is now available for not only AS2 and AS3 but C#, ColdFusion, Java, Perl, PHP, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.puremvc.org">The PureMVC framework</a> is <a href="http://www.asserttrue.com/articles/2007/10/17/silvafug-application-frameworks-presentation">considered one of the best</a> for Flash/Flex development (<a href="http://puremvc.org/component/option,com_wrapper/Itemid,30/">definitely the best documented</a>), I hadn&#8217;t checked out the site in a while (which has undergone an overhaul and is much improved!) and since my last visit PureMVC is now available for not only AS2 and AS3 but C#, ColdFusion, Java, Perl, PHP, Python, and Ruby as well.</p>
<p>I should say plans for Ruby as they are <a href="http://puremvc.org/component/option,com_wrapper/Itemid,169/">looking for a project owner</a> to work on the port. I&#8217;d volunteer myself (famous last words) but while I love Ruby I don&#8217;t know the ins and outs of the language as well as I do ActionScript.</p>
<p>In any case having one framework &#8220;to rule them all&#8221; would be a great boost to productivity as you wouldn&#8217;t have to mentally switch gears between the front (Flash/Flex) and back (PHP/Ruby etc.) ends.</p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/eq2qF2X7ZOA&#038;hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/eq2qF2X7ZOA&#038;hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alastairdawson.com/2008/03/28/puremvc-for-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build Flash with Ruby</title>
		<link>http://blog.alastairdawson.com/2008/03/24/build-flash-with-ruby/</link>
		<comments>http://blog.alastairdawson.com/2008/03/24/build-flash-with-ruby/#comments</comments>
		<pubDate>Mon, 24 Mar 2008 15:05:16 +0000</pubDate>
		<dc:creator>Alastair</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.vixiom.com/2008/03/24/build-flash-with-ruby/</guid>
		<description><![CDATA[Via Flex on Rails&#8230;
Using HotRuby it is possible to use straight Ruby to build a Flash app.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://flexonrails.net/?p=110">Via Flex on Rails&#8230;</a></p>
<blockquote><p>Using HotRuby it is possible to use straight Ruby to build a Flash app.</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.alastairdawson.com/2008/03/24/build-flash-with-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run Ruby code in the Flash Player?</title>
		<link>http://blog.alastairdawson.com/2008/02/26/run-ruby-code-in-the-flash-player/</link>
		<comments>http://blog.alastairdawson.com/2008/02/26/run-ruby-code-in-the-flash-player/#comments</comments>
		<pubDate>Wed, 27 Feb 2008 02:30:59 +0000</pubDate>
		<dc:creator>Alastair</dc:creator>
				<category><![CDATA[AIR]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[RIA]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Silverlight]]></category>

		<guid isPermaLink="false">http://blog.vixiom.com/2008/02/26/run-ruby-code-in-the-flash-player/</guid>
		<description><![CDATA[Or even better write Flash/Flex Rich Internet Applications with Ruby? Ted Patrick says it may soon be possible.
When Microsoft released Silverlight the one feature that got a lot of people excited was that you could use the language you were most familiar with to build a RIA. Apparently Adobe has an internal project which allows [...]]]></description>
			<content:encoded><![CDATA[<p>Or even better write Flash/Flex Rich Internet Applications with Ruby? <a href="http://www.onflex.org/ted/2008/02/extending-adobe-flash-player-and-adobe.php">Ted Patrick says it may soon be possible</a>.</p>
<p>When Microsoft released Silverlight the one feature that got a lot of people excited was that you could use the language you were most familiar with to build a RIA. Apparently Adobe has an internal project which allows any C or C++ code to run in the Flash Player or on AIR. This means that any language built on C/C++ will also run which means that Java, Python, and my beloved Ruby could also run. Schwing! <img src='http://blog.alastairdawson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Ted is a Python guy so he talks about IronPython and JPython but of course Ruby has <a href="http://jruby.codehaus.org/">JRuby</a> and <a href="http://www.ironruby.net/">IronRuby</a> so I&#8217;m sure the behavior would be similar.</p>
<blockquote><p>Like many organizations Adobe has lots of legacy C/C++ code ranging from PhotoShop filters, to PDF renderers, to readers and writers of every file format in existence, font libraries, to very complex vector renderers, and text layout code. Beyond Adobe there are many open source libraries that could be leveraged as components as well. The big thing for me is that these are not ports of these libraries, they run identical to the original source code down. For example the behavior of Python in Flash Player is identical to C-Python vs the ported behavior under the IronPython and Jython projects. The goal here is to bring lots of these legacy assets, code libraries, and languages into Flash Player and Adobe AIR perfectly so that any developer can leverage them cross-platform to build software. It would not shock me to see some of these components added into the Flash Player component cache so that they essentially are built into the player on first use.</p></blockquote>
<p><a href="http://www.infoworld.com/article/08/02/26/adobe-player_1.html">InfoWorld has more</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alastairdawson.com/2008/02/26/run-ruby-code-in-the-flash-player/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex, Flash, and Ruby hourly billing rates</title>
		<link>http://blog.alastairdawson.com/2008/02/02/flex-flash-and-ruby-hourly-billing-rates/</link>
		<comments>http://blog.alastairdawson.com/2008/02/02/flex-flash-and-ruby-hourly-billing-rates/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 22:27:49 +0000</pubDate>
		<dc:creator>Alastair</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Remoting]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://blog.vixiom.com/2008/02/02/flex-flash-and-ruby-hourly-billing-rates/</guid>
		<description><![CDATA[HotGigs has a feature where they collect and aggregate the hourly bill rates of the consultants on their site. Here are the average hourly bill rates for Flex, Flash, and Ruby, surprisingly they have sub-categories for Flash all the way down to Flash Remoting but there&#8217;s just one category for Ruby with no Rails sub-category.
For [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.hotgigs.com">HotGigs</a> has a feature where they collect and aggregate the hourly bill rates of the consultants on their site. Here are the average hourly bill rates for Flex, Flash, and Ruby, surprisingly they have sub-categories for Flash all the way down to Flash Remoting but there&#8217;s just one category for Ruby with no Rails sub-category.</p>
<p>For the Rails rate I&#8217;d guess that Rails is to Ruby as Flex is to ActionScript. I threw PHP in there as well to mix it up.</p>
<p><strong>ActionScript hourly bill rates</strong><br />
ActionScript bill rate (low):  $50.00<br />
ActionScript bill rate (high):  $75.00<br />
ActionScript pay rate (low):  $32.50<br />
ActionScript pay rate (high):  $48.75<br />
Average hourly bill rate: $62.50</p>
<p><strong>Adobe Flex hourly bill rates</strong><br />
Adobe Flex bill rate (low):  $75.00<br />
Adobe Flex bill rate (high):  $125.00<br />
Adobe Flex pay rate (low):  $48.75<br />
Adobe Flex pay rate (high):  $81.25<br />
Average hourly bill rate: $100.00</p>
<p><strong>Flash hourly bill rates</strong><br />
Flash bill rate (low):  $50.00<br />
Flash bill rate (high):  $75.00<br />
Flash pay rate (low):  $32.50<br />
Flash pay rate (high):  $48.75<br />
Average hourly bill rate: $62.50</p>
<p><strong>Flash Design</strong> (no full data but this was the average)<br />
Average hourly bill rate: $50</p>
<p><strong>Flash Remoting hourly bill rates</strong><br />
Flash Remoting bill rate (low):  $60.00<br />
Flash Remoting bill rate (high):  $80.00<br />
Flash Remoting pay rate (low):  $39.00<br />
Flash Remoting pay rate (high):  $52.00<br />
Average hourly bill rate: $70.00</p>
<p><strong>Ruby hourly bill rates</strong><br />
Ruby bill rate (low):  $75.00<br />
Ruby bill rate (high):  $95.00<br />
Ruby pay rate (low):  $48.75<br />
Ruby pay rate (high):  $61.75<br />
Average hourly bill rate: $85.00</p>
<p><strong>PHP hourly bill rates</strong><br />
PHP bill rate (low):  $70.00<br />
PHP bill rate (high):  $90.00<br />
PHP pay rate (low):  $45.50<br />
PHP pay rate (high):  $58.50<br />
Average hourly bill rate: $80.00</p>
<p>Flex had an <a href="http://seantheflashguy.com/blog/2007/11/30/adobe-flex-hourly-billing-rates-via-hotgigs/">average hourly bill rate of $70</a> a couple of months ago so it&#8217;s on the move (what recession?), if you&#8217;re an ActionScript Developer still doing Flash work get on the Flex train and raise those rates!</p>
<p>The rates seem about right to me (actually remoting seems low), what do you think?</p>
<p><object width="425" height="355"><param name="movie" value="http://www.youtube.com/v/pBhic4fzuYk&#038;rel=0&#038;color1=0xd6d6d6&#038;color2=0xf0f0f0&#038;border=0"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/pBhic4fzuYk&#038;rel=0&#038;color1=0xd6d6d6&#038;color2=0xf0f0f0&#038;border=0" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alastairdawson.com/2008/02/02/flex-flash-and-ruby-hourly-billing-rates/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Regular expressions make my head hurt</title>
		<link>http://blog.alastairdawson.com/2008/01/22/regular-expressions-make-my-head-hurt/</link>
		<comments>http://blog.alastairdawson.com/2008/01/22/regular-expressions-make-my-head-hurt/#comments</comments>
		<pubDate>Tue, 22 Jan 2008 20:58:57 +0000</pubDate>
		<dc:creator>Alastair</dc:creator>
				<category><![CDATA[RegEx]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://blog.vixiom.com/2008/01/22/regular-expressions-make-my-head-hurt/</guid>
		<description><![CDATA[A site to dull the pain Rubular. Via Ruby Inside.
]]></description>
			<content:encoded><![CDATA[<p>A site to dull the pain <a href="http://www.rubular.com/">Rubular</a>. Via <a href="http://www.rubyinside.com/interesting-ruby-tidbits-that-dont-need-separate-posts-14-699.html">Ruby Inside</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alastairdawson.com/2008/01/22/regular-expressions-make-my-head-hurt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails 2.0 and link_to_remote :with</title>
		<link>http://blog.alastairdawson.com/2008/01/18/rails-20-and-link_to_remote-with/</link>
		<comments>http://blog.alastairdawson.com/2008/01/18/rails-20-and-link_to_remote-with/#comments</comments>
		<pubDate>Fri, 18 Jan 2008 18:22:18 +0000</pubDate>
		<dc:creator>Alastair</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://blog.vixiom.com/2008/01/18/rails-20-and-link_to_remote-with/</guid>
		<description><![CDATA[I&#8217;m moving an old app to Rails 2.0 and other than fixing some routes Ajax calls with link_to_remote and the :with parameter was the only thing that gave me some trouble. In the old version I was grabbing the current value of a drop down list with Prototype and passing it along using :with like [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m moving an old app to Rails 2.0 and other than fixing some routes Ajax calls with link_to_remote and the :with parameter was the only thing that gave me some trouble. In the old version I was grabbing the current value of a drop down list with Prototype and passing it along using :with like this</p>
<pre class="textmate-source"><span class="text text_html text_html_ruby"><span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%=</span> link_to_remote image_tag<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>cms/add_16.gif<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>id</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>color_add<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span>
      <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>url</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby">{</span><span class="meta meta_syntax meta_syntax_ruby meta_syntax_ruby_start-block"> </span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>controller</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>colors<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>action</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>new_ajax<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span>
      <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>id</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>product</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>id <span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby">}</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span>
      <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>with</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>{ color_id: $F('color_id') }<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span></span></pre>
<p>But in Rails 2.0 the parameter wouldn&#8217;t go along for the ride, it seemed that the new authenticity_token that gets sent with Ajax calls was messing things up. Here&#8217;s the fix</p>
<pre class="textmate-source"><span class="text text_html text_html_ruby"><span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%=</span> link_to_remote image_tag<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>cms/add_16.gif<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>id</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>color_add<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span>
      <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>url</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby">{</span><span class="meta meta_syntax meta_syntax_ruby meta_syntax_ruby_start-block"> </span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>controller</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>colors<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>action</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>new_ajax<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span>
      <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>id</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>product</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>id <span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby">}</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span>
      <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>with</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="string string_quoted string_quoted_double string_quoted_double_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">"</span>'color_id='+$F('color_id')<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">"</span></span>
<span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span></span></pre>
<p>I freely admit JavaScript/Ajax is my weakest language so if I was doing it wrong the entire time let me know <img src='http://blog.alastairdawson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alastairdawson.com/2008/01/18/rails-20-and-link_to_remote-with/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rails: cleaner partials in forms</title>
		<link>http://blog.alastairdawson.com/2008/01/18/rails-cleaner-partials-in-forms/</link>
		<comments>http://blog.alastairdawson.com/2008/01/18/rails-cleaner-partials-in-forms/#comments</comments>
		<pubDate>Fri, 18 Jan 2008 18:04:50 +0000</pubDate>
		<dc:creator>Alastair</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://blog.vixiom.com/2008/01/18/rails-cleaner-partials-in-forms/</guid>
		<description><![CDATA[Damian pointed me to the patch ELC Technologies committed to Rails.
As he mentions previously you did something like
&#60;% form_for(@client) do &#124;f&#124; %&#62;
    &#60;%= render :partial =&#62; 'form', :locals =&#62; {:f =&#62; f} %&#62;
    &#60;%= submit_tag 'Create' %&#62;
&#60;% end %&#62;
but now you can just do&#8230;
&#60;% form_for(@client) do &#124;f&#124; %&#62;
  [...]]]></description>
			<content:encoded><![CDATA[<p>Damian <a href="http://elctech.com/2008/1/16/patching-rails-rendering-form-partials">pointed me to</a> the patch <a href="http://elctech.com/">ELC Technologies</a> committed to Rails.</p>
<p>As he mentions previously you did something like</p>
<pre class="textmate-source"><span class="text text_html text_html_ruby"><span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%</span> form_for<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>client</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do </span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span><span class="variable variable_other variable_other_block variable_other_block_ruby">f</span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>
    <span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%=</span> <span class="support support_function support_function_actionpack support_function_actionpack_rails">render</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>partial</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>form<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>locals</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby">{</span><span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>f</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> f<span class="punctuation punctuation_section punctuation_section_scope punctuation_section_scope_ruby">}</span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>
    <span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%=</span> submit_tag <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>Create<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>
<span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%</span> <span class="keyword keyword_control keyword_control_ruby">end</span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span></span></pre>
<p>but now you can just do&#8230;</p>
<pre class="textmate-source"><span class="text text_html text_html_ruby"><span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%</span> form_for<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="variable variable_other variable_other_readwrite variable_other_readwrite_instance variable_other_readwrite_instance_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@</span>client</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <span class="keyword keyword_control keyword_control_start-block keyword_control_start-block_ruby">do </span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span><span class="variable variable_other variable_other_block variable_other_block_ruby">f</span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>
    <span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%=</span> <span class="support support_function support_function_actionpack support_function_actionpack_rails">render</span> <span class="constant constant_other constant_other_symbol constant_other_symbol_ruby"><span class="punctuation punctuation_definition punctuation_definition_constant punctuation_definition_constant_ruby">:</span>partial</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> f <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>
    <span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%=</span> submit_tag <span class="string string_quoted string_quoted_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>Create<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>
<span class="source source_ruby source_ruby_rails source_ruby_rails_embedded source_ruby_rails_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%</span> <span class="keyword keyword_control keyword_control_ruby">end</span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span></span></pre>
<p>Cleaner and more intuitive, nice!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.alastairdawson.com/2008/01/18/rails-cleaner-partials-in-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
