<?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>Chris Irish &#124; Ruby, Rails, Javascript Developer &#124; Phoenix, AZ</title>
	<atom:link href="http://www.christopherirish.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christopherirish.com</link>
	<description>Ruby, Rails, Javascript, all things web development related</description>
	<lastBuildDate>Mon, 19 Jan 2026 07:43:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Web Development Services</title>
		<link>http://www.christopherirish.com/2012/06/21/freelance-work/</link>
		<comments>http://www.christopherirish.com/2012/06/21/freelance-work/#comments</comments>
		<pubDate>Thu, 21 Jun 2012 23:41:25 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=855</guid>
		<description><![CDATA[Just wanted to make a quick post that if you&#8217;re interested in Ruby on Rails Development, please contact me over at Velocity Labs instead of here. Thanks!]]></description>
			<content:encoded><![CDATA[<p></p><p>Just wanted to make a quick post that if you&#8217;re interested in <a title="Velocity Labs" href="http://velocitylabs.io" target="_blank">Ruby on Rails Development</a>, please contact me over at <a title="Velocity Labs" href="http://velocitylabs.io" target="_blank">Velocity Labs</a> instead of here. Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2012/06/21/freelance-work/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RailsConf RubyAZ Presentation Slides</title>
		<link>http://www.christopherirish.com/2012/05/16/railsconf-rubyaz-presentation-slides/</link>
		<comments>http://www.christopherirish.com/2012/05/16/railsconf-rubyaz-presentation-slides/#comments</comments>
		<pubDate>Wed, 16 May 2012 07:00:39 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=842</guid>
		<description><![CDATA[This past Tuesday evening I presented to the RubyAZ user group. The talk covered useful libraries and gems that I saw at Rails Conf 2012 that I thought others might find helpful in their day to day work. I&#8217;ve made the presentation slides available as a pdf. Enjoy!]]></description>
			<content:encoded><![CDATA[<p></p><p>This past Tuesday evening I presented to the RubyAZ user group.  The talk covered useful libraries and gems that I saw at Rails Conf 2012 that I thought others might find helpful in their day to day work.  I&#8217;ve made the <a href="https://www.dropbox.com/s/4tsrlwgbgb045yg/RailsConfPreso.pdf" target="_blank">presentation slides</a> available as a pdf.  Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2012/05/16/railsconf-rubyaz-presentation-slides/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to set the timezone on Ubuntu Server</title>
		<link>http://www.christopherirish.com/2012/03/21/how-to-set-the-timezone-on-ubuntu-server/</link>
		<comments>http://www.christopherirish.com/2012/03/21/how-to-set-the-timezone-on-ubuntu-server/#comments</comments>
		<pubDate>Thu, 22 Mar 2012 00:28:56 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=792</guid>
		<description><![CDATA[I find it&#8217;s pretty annoying when you have to go log file spelunking only to find all the timestamps are in UTC.  But we can set the timezone of the server so when Rails, cron, scripts, etc run, they output more readable dates. You can check your current timezone by just running $ dateThu Mar 21 [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I find it&#8217;s pretty annoying when you have to go log file spelunking only to find all the timestamps are in UTC.  But we can set the timezone of the server so when Rails, cron, scripts, etc run, they output more readable dates.</p>
<p>You can check your current timezone by just running</p>

<div class="wp-terminal">$ date<br/>Thu Mar 21 18:02:49 MST 2012<br/><br/></div>

<p>Or checking the timezone file at</p>

<div class="wp-terminal">$ more /etc/timezone<br/>US/Arizona<br/><br/></div>

<p>So to change it just run</p>

<div class="wp-terminal">$ sudo dpkg-reconfigure tzdata<br/></div>

<p>And follow on screen instructions.  Easy.</p>
<p>Also be sure to restart cron as it won&#8217;t pick up the timezone change and will still be running on UTC.</p>

<div class="wp-terminal">$ /etc/init.d/cron stop<br/>$ /etc/init.d/cron start<br/></div>

<p>UPDATE July 2016<br />
In the comments Dan mentions that in 16.04 you use something like:</p>

<div class="wp-terminal">$ sudo timedatectl set-timezone Australia/Melbourne<br/></div>

<div id="hire" class="text-center">
  <a href="http://velocitylabs.io"><img src="http://www.christopherirish.com/wp-content/uploads/2018/07/velocity-labs-logo-text.png" alt="" title="velocity-labs-logo-text" width="300" class="alignleft size-full wp-image-971" /></a></p>
<p>
    Need web application development, maintenance for your existing app, or a third party code review?
  </p>
<p>
    <strong class="text-uppercase">Velocity Labs can help.</strong>
  </p>
<p>  <a href="http://velocitylabs.io#contact" class="btn btn-warning btn-block" target="_blank">Click here to get started!</a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2012/03/21/how-to-set-the-timezone-on-ubuntu-server/feed/</wfw:commentRss>
		<slash:comments>63</slash:comments>
		</item>
		<item>
		<title>Can&#8217;t get SSH Public Keys working?</title>
		<link>http://www.christopherirish.com/2012/01/27/cant-get-ssh-public-key-working/</link>
		<comments>http://www.christopherirish.com/2012/01/27/cant-get-ssh-public-key-working/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 00:23:40 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=756</guid>
		<description><![CDATA[Having problems getting ssh to use your public key? Log on to your server as root using a password. Remember not to log out as root until you have ssh working with your public key or you may inadvertently lock yourself off the box.. which sucks Double check your sshd_config, I use the following options [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Having problems getting ssh to use your public key?</p>
<p>Log on to your server as root using a password. Remember not to log out as root until you have ssh working with your public key or you may inadvertently lock yourself off the box.. which sucks <img src='http://www.christopherirish.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  Double check your sshd_config, I use the following options (note you will have to restart ssh for these changes to take effect):</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Port 30000 &nbsp; &nbsp;&lt;--- change to a port of your choosing<br />
Protocol 2<br />
PermitRootLogin no<br />
PasswordAuthentication no<br />
UseDNS no<br />
AllowUsers deploy &nbsp; &lt;--- change to whatever users you want<br />
ClientAliveInterval 30<br />
ClientAliveCountMax 4</div></td></tr></tbody></table></div>
<p>Make sure your public key is in the .ssh/authorized_keys file for the user you plan on logging onto the server as.  You can use this super helpful <a href="http://www.christopherirish.com/2010/04/19/the-authme-ssh-key-bash-function/" title="authme bash function">authme bash function</a>.</p>
<p>So let&#8217;s say you&#8217;ve done all this and YOU STILL CAN&#8217;T get it to work.  It&#8217;s probably because you have incorrect permissions set on the .ssh directory and/or the authorized_keys file.  You can check this by looking at the ssh auth log. Depending on your server OS it&#8217;s usually either /var/log/auth.log or /var/log/secure .  Tail this file and see if you&#8217;re getting this message</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Authentication refused: bad ownership or modes for directory /home/deploy/.ssh</div></td></tr></tbody></table></div>
<p>Obviously your directory will be different depending on the name of the user you&#8217;re trying to ssh on as. But this message is the give away that your permissions are wrong.  Change them with the following, assuming your username is &#8220;deploy&#8221;, otherwise just substitute that part.</p>

<div class="wp-terminal">$ chmod go-w /home/deploy/<br/>$ chmod 700  /home/deploy/.ssh<br/>$ chmod 600  /home/deploy/.ssh/authorized_keys<br/><br/></div>

<p>Try ssh&#8217;ing on again in another terminal window and you should be good. Now it would be safe to log off as root.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2012/01/27/cant-get-ssh-public-key-working/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>No view_context, in views, in Rails 3.1 changes</title>
		<link>http://www.christopherirish.com/2011/10/13/no-view_context-in-rails-3-1-changes/</link>
		<comments>http://www.christopherirish.com/2011/10/13/no-view_context-in-rails-3-1-changes/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 05:35:11 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=658</guid>
		<description><![CDATA[Got burned by two things today in one of my apps by upgrading to Rails 3.1. The first thing was a few nested forms stopped working when editing an existing record that had child records. None of the children were getting rendered. For briefity, the form basically was like: &#60;%= form_for @meal do &#124;meal_form&#124; %&#62; [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Got burned by two things today in one of my apps by upgrading to Rails 3.1.  The first thing was a few nested forms stopped working when editing an existing record that had child records. None of the children were getting rendered.  For briefity, the form basically was like:</p>
<pre class="textmate-source sunburst" style="padding: 5px 10px;"><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> <span class="support support_function support_function_viewhelpers support_function_viewhelpers_rails">form_for</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>meal</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">meal_form</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="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">table</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>
    <span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">tbody</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&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> meal_form<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span><span class="support support_function support_function_viewhelpers support_function_viewhelpers_rails">fields_for</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>meal_items</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">item_form</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>meal_item_fields<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="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>f</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> item_form <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> <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 class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">tbody</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>
  <span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;/</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">table</span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&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>Can you spot the error?  Once I spotted it I felt rather dumb myself.  It&#8217;s the following erb tag</p>
<pre class="textmate-source sunburst"><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> meal_form<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span><span class="support support_function support_function_viewhelpers support_function_viewhelpers_rails">fields_for</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>meal_items</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">item_form</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></pre>
<p>Ya even when they&#8217;re nested you HAVE to use the <%= form... doh! </p>
<pre class="textmate-source sunburst"><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> meal_form<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span><span class="support support_function support_function_viewhelpers support_function_viewhelpers_rails">fields_for</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>meal_items</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">item_form</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></pre>
<p>The second problem I ran into, and which I still don't have an answer for, though if you do answer my <a href="http://stackoverflow.com/questions/7761557/view-context-not-longer-available-in-rails-3-views">StackOverflow question</a>.  Basically, in Rails 2.3 if you needed to get at an instance of the Template Builder you could use @template, but then they changed it in Rails 3 to a special method called "view_context".  Far enough, so I was using view_context in Rails 3.0.X to create nested forms (other than the one above) dynamically using jQuery ajax and js.erb partials.  Using view_context allowed me to call fields_for off of it so that I would get nicely named form_fields when I didn't have the parent FormBuilder handy.  Like this</p>
<p>In some_view.js.erb</p>
<pre class="textmate-source sunburst"><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> fields <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span>
    view_context<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span><span class="support support_function support_function_viewhelpers support_function_viewhelpers_rails">fields_for</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>meal_items</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="support support_class support_class_ruby">Meal</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_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>meal_items<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="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="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>meal_item_fields<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="keyword keyword_control keyword_control_ruby">end</span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>

$("#meal-items").append("<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> escape_javascript<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>fields<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span>");</span></pre>
<p>But once I upgrade to 3.1, I started getting the following error</p>
<pre>
ActionView::Template::Error (undefined local variable or method `view_context' for #<#:0x1057b9f70>):
</pre>
<p>Perhaps this was removed as the Core team figured, why do you need the view_context available when you're in a view template already... but I don't know.  I was able to workaround it though by moving my code up into the controller. Which does seem to be a violation of the MVC separation, but I couldn't find any other way to make it work like pre Rails upgrade. So instead of creating a local variable "fields", this became an instance variable that was set in the controller action.  And render needed to become render_to_string with an html_safe call tacked on the end.</p>
<p>In controller</p>
<pre class="textmate-source sunburst"><span class="source source_ruby source_ruby_rails"><span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">some_ajax_action</span></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>fields</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span>
    view_context<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span><span class="support support_function support_function_viewhelpers support_function_viewhelpers_rails">fields_for</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>meal_items</span><span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span> <span class="support support_class support_class_ruby">Meal</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_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>meal_items<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="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>
      render_to_string<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_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>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>fields<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_function punctuation_section_function_ruby">)</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>html_safe
    <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>I don't like this, but it'll do for now I suppose. And now in some_view.js.erb</p>
<pre class="textmate-source sunburst"><span class="source source_ruby source_ruby_rails">$<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>#meal-items<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_method punctuation_separator_method_ruby">.</span>append<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>&lt;%= escape_javascript(@fields) %&gt;<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_statement punctuation_separator_statement_ruby">;</span></span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2011/10/13/no-view_context-in-rails-3-1-changes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ruby 1.9.2 Segmentation Fault and OpenSSL</title>
		<link>http://www.christopherirish.com/2011/09/02/ruby-1-9-2-segmentation-fault-and-openssl/</link>
		<comments>http://www.christopherirish.com/2011/09/02/ruby-1-9-2-segmentation-fault-and-openssl/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 22:20:44 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=633</guid>
		<description><![CDATA[In one of my current project, whenever I ran a rake task that did a net/http request it was causing segmentation faults. $ bundle exec rake test:task$ /Users/cirish/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:678: [BUG] Segmentation faultruby 1.9.2 (2011-06-30 patchlevel 290) [i686-darwin10.8.0] And it seems whenever I get a segmentation fault the first place I need to look is at OpenSSL. [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>In one of my current project, whenever I ran a rake task that did a net/http request it was causing segmentation faults.</p>

<div class="wp-terminal">$ bundle exec rake test:task<br/>$ /Users/cirish/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/net/http.rb:678: [BUG] Segmentation fault<br/>ruby 1.9.2 (2011-06-30 patchlevel 290) [i686-darwin10.8.0]<br/><br/></div>

<p>And it seems whenever I get a segmentation fault the first place I need to look is at OpenSSL.  I&#8217;ve had similar problems with seg faults and openssl in the past, namely this <a href=" http://www.christopherirish.com/2010/06/21/ruby-1-8-7-openssl-bus-error/">OpenSSL Bus Error</a> that I was getting on Ruby 1.8.7.</p>
<p>If you read that post you&#8217;ll see this happened because I use MacPorts and have OpenSSL installed through it, in addition to a local OS X version.  To get Ruby to be happy, you have to point your Ruby install to the correct version at installation time. So remove the bad install</p>

<div class="wp-terminal">$ rvm remove ruby-1.9.2<br/></div>

<p>And reinstall</p>

<div class="wp-terminal">$ rvm install ruby-1.9.2 --with-openssl-dir=/opt/local --with-iconv-dir=$rvm_path/usr<br/></div>

<p>Which I forgot to do with my Ruby 1.9.2 install after upgrading OS X versions.  That last bit about iconv isn&#8217;t directly related, but I have inconv package installed to RVM, you can read about that here <a href="http://beginrescueend.com/packages/iconv/">RVM Iconv</a>.  </p>
<p>Also, this Phusion blog post <a href="http://blog.phusion.nl/2011/02/24/ruby-enterprise-edition-1-8-7-2011-03-released/">REE 1-8-7-2011-03-released</a> mentions problems with OpenSSL and MacPorts.  Moral of the story&#8230; use HomeBrew? Dunno, but I&#8217;ll probably start using it when I upgrade my laptop.</p>
<div id="hire" class="text-center">
  <a href="http://velocitylabs.io"><img src="http://www.christopherirish.com/wp-content/uploads/2018/07/velocity-labs-logo-text.png" alt="" title="velocity-labs-logo-text" width="300" class="alignleft size-full wp-image-971" /></a></p>
<p>
    Need web application development, maintenance for your existing app, or a third party code review?
  </p>
<p>
    <strong class="text-uppercase">Velocity Labs can help.</strong>
  </p>
<p>  <a href="http://velocitylabs.io#contact" class="btn btn-warning btn-block" target="_blank">Click here to get started!</a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2011/09/02/ruby-1-9-2-segmentation-fault-and-openssl/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Rails 3 Authlogic sessions not persisting in production</title>
		<link>http://www.christopherirish.com/2011/08/12/rails-3-authlogic-sessions-not-persisting-in-production/</link>
		<comments>http://www.christopherirish.com/2011/08/12/rails-3-authlogic-sessions-not-persisting-in-production/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 19:16:43 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=622</guid>
		<description><![CDATA[I just ran into a rather hard to track down issue with Authlogic and Rails 3. After upgrading an old app to Rails 3, in production, the sessions wouldn&#8217;t persist, but everything worked fine in development mode. After much searching it turns out that there&#8217;s an issue with using Rails 3, Authlogic, and HTTP auth [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I just ran into a rather hard to track down issue with Authlogic and Rails 3.  After upgrading an old app to Rails 3, in production, the sessions wouldn&#8217;t persist, but everything worked fine in development mode.  After much searching it turns out that there&#8217;s an issue with using Rails 3, Authlogic, and HTTP auth together.  I had put up HTTP basic auth in Nginx to prevent the site from getting seen by random people or web crawlers.  When the app was a Rails 2 app, there was no issue, in fact the Rails app shouldn&#8217;t even have known about the HTTP auth since I was doing it in Nginx, not Rails.  Not sure why this is a problem with this Rails/Authlogic/HTTP combination, but anyways, the fix was to add this one-liner to your UserSession model</p>
<pre class="textmate-source sunburst"><span class='linenum'>    1</span> <span class="source source_ruby"><span class="meta meta_class meta_class_ruby"><span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">UserSession<span class="entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby"> <span class="punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby">&lt;</span> Authlogic::Session::Base</span></span></span>
<span class='linenum'>    2</span>   allow_http_basic_auth <span class="constant constant_language constant_language_ruby">false</span>
<span class='linenum'>    3</span> <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2011/08/12/rails-3-authlogic-sessions-not-persisting-in-production/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Splitting Rails DOM ids with RegEx Look Aheads</title>
		<link>http://www.christopherirish.com/2010/10/15/splitting-rails-dom-ids-with-regex-look-aheads/</link>
		<comments>http://www.christopherirish.com/2010/10/15/splitting-rails-dom-ids-with-regex-look-aheads/#comments</comments>
		<pubDate>Fri, 15 Oct 2010 08:27:02 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Regular Expressions]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=530</guid>
		<description><![CDATA[In my Rails erb views I make good use of the dom_id view helper method. It basically introspects the object you pass to it and creates a unique id to use in your markup, based on the object type and database id. So for example if I had a Post with id 1, I could [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>In my Rails erb views I make good use of the dom_id view helper method.  It basically introspects the object you pass to it and creates a unique id to use in your markup, based on the object type and database id.  So for example if I had a Post with id 1, I could do:</p>
<pre class="textmate-source sunburst"><span class='linenum'>    1</span> <span class="text text_html text_html_ruby">
<span class='linenum'>    2</span> <span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">li</span> <span class="meta meta_attribute-with-value meta_attribute-with-value_id meta_attribute-with-value_id_html"><span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_id entity_other_attribute-name_id_html">id</span><span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_html">=</span><span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span><span class="meta meta_toc-list meta_toc-list_id meta_toc-list_id_html"><span class="source source_ruby source_ruby_embedded source_ruby_embedded_html"><span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">&lt;%=</span> dom_id<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>post</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span> <span class="punctuation punctuation_section punctuation_section_embedded punctuation_section_embedded_ruby">%&gt;</span></span></span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span></span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>
</span><span class='linenum'>    3</span> </pre>
<p>And it would be rendered as</p>
<pre class="textmate-source sunburst"><span class='linenum'>    1</span> <span class="text text_html text_html_ruby">
<span class='linenum'>    2</span> <span class="meta meta_tag meta_tag_inline meta_tag_inline_any meta_tag_inline_any_html"><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_begin punctuation_definition_tag_begin_html">&lt;</span><span class="entity entity_name entity_name_tag entity_name_tag_inline entity_name_tag_inline_any entity_name_tag_inline_any_html">li</span> <span class="meta meta_attribute-with-value meta_attribute-with-value_id meta_attribute-with-value_id_html"><span class="entity entity_other entity_other_attribute-name entity_other_attribute-name_id entity_other_attribute-name_id_html">id</span><span class="punctuation punctuation_separator punctuation_separator_key-value punctuation_separator_key-value_html">=</span><span class="string string_quoted string_quoted_double string_quoted_double_html"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_html">"</span><span class="meta meta_toc-list meta_toc-list_id meta_toc-list_id_html">post_1</span><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_html">"</span></span></span><span class="punctuation punctuation_definition punctuation_definition_tag punctuation_definition_tag_end punctuation_definition_tag_end_html">&gt;</span></span>
</span><span class='linenum'>    3</span> </pre>
<p>This is fine until you use dom_id on an object with a compound name like EmailNotification. Now dom_id will create a unique id like</p>
<p>email_notification_1</p>
<p>Which is still good until I&#8217;m doing some front-end testing and I&#8217;m parsing these dom ids to find their related db records.  Now I need to split &#8220;email_notification_1&#8243; in a way that easily separates the object class from the identifier.  How would you do that? </p>
<p>Well, what we can do here is use an advanced Regular Expression feature called a negative look ahead.  We want to say, &#8220;split the string on the last underscore&#8221;.</p>
<p>A negative look ahead uses the ?! syntax in parenthesis, everything that follows ?! in the parenthesis will be used in the negative look ahead matching.  So in our case we want to say, there should be a underscore that can be followed by any character except another underscore.  The pattern would like like this:</p>
<pre>
/_(?!.*_)/
</pre>
<p>We can confirm in irb</p>

<div class="wp-terminal">$ ree-1.8.7-head > x = "email_notification_1234"<br/>=> "email_notification_1234"<br/>ree-1.8.7-head > klass, id = x.split(/_(?!.*_)/)<br/>=> ["email_notification", "1234"] <br/></div>

<p>Likewise, If we wanted to split the dom_id on the first underscore we could just use a regular look ahead.  It is similar but uses the ?= syntax.</p>

<div class="wp-terminal">$ ree-1.8.7-head > x.split(/_(?=.*_)/)<br/>=> ["email", "notification_1234"]<br/></div>

]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2010/10/15/splitting-rails-dom-ids-with-regex-look-aheads/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to install RVM on Ubuntu 10.04</title>
		<link>http://www.christopherirish.com/2010/08/25/how-to-install-rvm-on-ubuntu-10-04/</link>
		<comments>http://www.christopherirish.com/2010/08/25/how-to-install-rvm-on-ubuntu-10-04/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 08:21:09 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Installation]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RVM]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=474</guid>
		<description><![CDATA[I&#8217;ve heard people describe frustrations they had in getting Rails 3 setup on Ubuntu 10.04 with Ruby 1.9.2. I&#8217;m going to outline the steps I&#8217;ve taken to do this. Let&#8217;s get started installing RVM. It should be noted that I created a fresh slice on my Rackspace Cloud account to create this tutorial. And I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I&#8217;ve heard people describe frustrations they had in getting Rails 3 setup on Ubuntu 10.04 with Ruby 1.9.2.  I&#8217;m going to outline the steps I&#8217;ve taken to do this.  Let&#8217;s get started installing RVM.</p>
<p>It should be noted that I created a fresh slice on my <a href="http://www.rackspacecloud.com/1655-0-3-13.html" target="_blank">Rackspace Cloud</a> account to create this tutorial.  And I&#8217;m assuming you&#8217;ve already setup SSH.</p>

<div class="wp-terminal">$ ssh root@173.XXX.XXX.XXX<br/>&lt;-- Output Snipped --&gt;<br/>root@173.XXX.XXX.XXX's password:<br/>&lt;-- Output Snipped --&gt;<br/></div>

<p>Alright, so lets confirm we don&#8217;t have ruby installed</p>

<div class="wp-terminal">$ which ruby<br/>$ <br/></div>

<p>Cool, nada.  Let&#8217;s grab the basic dependencies</p>

<div class="wp-terminal">$ sudo apt-get install curl git-core ruby<br/>Reading package lists... Done<br/>Building dependency tree<br/>&lt;-- Output Snipped --&gt;<br/></div>

<p>Now we&#8217;ll install RVM as per their instructions</p>
<p>http://rvm.beginrescueend.com/rvm/install/</p>

<div class="wp-terminal">$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )<br/><br/>&lt;-- Output Snipped --&gt;<br/><br/>RVM:   shell scripts which allow management of multiple ruby interpreters and environments.<br/>RTFM:  http://rvm.beginrescueend.com/<br/>HELP:  http://webchat.freenode.net/?channels=rvm (#rvm on irc.freenode.net)<br/><br/>* Installing rvm to /usr/local/rvm/<br/>Correct permissions for base binaries in /usr/local/bin...<br/>Copying manpages into place.<br/><br/>Notes for Linux ( DISTRIB_ID=Ubuntu<br/>DISTRIB_RELEASE=10.04<br/>DISTRIB_CODENAME=lucid<br/>DISTRIB_DESCRIPTION="Ubuntu 10.04 LTS" )<br/><br/>&lt;-- Output Snipped --&gt;<br/><br/>*  For JRuby (if you wish to use it) you will need:<br/>$ aptitude install curl sun-java6-bin sun-java6-jre sun-java6-jdk<br/>*  For MRI &amp; ree (if you wish to use it) you will need (depending on what you are installing):<br/>$ aptitude install build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf<br/>*  For IronRuby (if you wish to use it) you will need:<br/>$ aptitude install curl mono-2.0-devel<br/><br/>&lt;-- Output Snipped --&gt;<br/><br/>WARNING:  you have a 'return' statement in your .bashrc, likely this will cause untold havoc.<br/>This means that if you see '[ -z "$PS1" ] &amp;&amp; return' then you must change this line to:<br/>if [[ -n "$PS1" ]] ; then<br/>... original content that was below the &amp;&amp; return line ...<br/>fi # &lt;= be sure to close the if.<br/>#EOF .bashrc<br/>Even if you use zsh you should still adjust the .bashrc as above.<br/>If you have any questions about this please visit #rvm on irc.freenode.net.<br/><br/>Installation of RVM to /usr/local/rvm/ is complete.<br/></div>

<p>The last part in there about the .bashrc file is important!  Using your editor of choice, open the .bashrc file that resides in your user directory.</p>
<p>You need to replace the line that says</p>
<pre>[ -z "$PS1" ] &amp;&amp; return</pre>
<p>with</p>
<pre>if [[ -n "$PS1" ]]; then</pre>
<p>Now add this to the last line of the file</p>
<pre>if [[ -s $HOME/.rvm/scripts/rvm ]] ; then source $HOME/.rvm/scripts/rvm ; fi

fi</pre>
<p>And yes there needs to be that last fi as it closes the one we added earlier. Save this file with our changes.  Now we can check if RVM is setup correctly.</p>

<div class="wp-terminal">$ rvm notes<br/></div>

<p>If this doesn&#8217;t work you may have to source your .bashrc file to have it reloaded by the current terminal session</p>

<div class="wp-terminal">$ source ~/.bashrc<br/></div>

<p>After running `rvm notes` if it gives you installation notes about RVM then you&#8217;re good to continue, otherwise double check you edited your .bashrc file correctly.</p>
<p>In the notes output RVM tells you what packages you&#8217;re gonna need to install for various flavors of Ruby.  Since we&#8217;re going with 1.9.2 we want the packages it lists under the MRI &#038; ree section.  Let&#8217;s install those now.</p>

<div class="wp-terminal">$ sudo aptitude install build-essential bison openssl libreadline5 libreadline-dev curl git-core zlib1g zlib1g-dev libssl-dev vim libsqlite3-0 libsqlite3-dev sqlite3 libreadline-dev libxml2-dev git-core subversion autoconf<br/><br/>&lt;-- A really long bit of Output Snipped --&gt;<br/><br/></div>

<p>Now we can look at all the RVM known Ruby packages</p>

<div class="wp-terminal">$ rvm list known<br/># MRI Rubies<br/>(ruby-)1.8.6(-p399)<br/>(ruby-)1.8.6-head<br/>(ruby-)1.8.7(-p302)<br/>(ruby-)1.8.7-head<br/>(ruby-)1.9.1-p243<br/>(ruby-)1.9.1-p376<br/>(ruby-)1.9.1(-p429)<br/>(ruby-)1.9.1-head<br/>(ruby-)1.9.2-preview1<br/>(ruby-)1.9.2-preview3<br/>(ruby-)1.9.2-rc1<br/>(ruby-)1.9.2-rc2<br/>(ruby-)1.9.2(-p0)<br/>(ruby-)1.9.2-head<br/>ruby-head<br/><br/># JRuby<br/>jruby-1.2.0<br/>jruby-1.3.1<br/>jruby-1.4.0<br/>jruby-1.5.1<br/>jruby(-1.5.2)<br/>jruby-head<br/><br/>&lt;-- Output Snipped --&gt;<br/></div>

<p>Next we install the version we want and set it as the default.  You&#8217;re gonna see RVM install ruby-1.8.7-p302 first, be patient as it will need to also install rubygems-1.3.7, before it finally gets to that 1.9.2.</p>

<div class="wp-terminal">$ rvm install 1.9.2-head<br/>&lt;-- Output Snipped --&gt;<br/>info: Installing ruby-1.8.7-p302<br/>&lt;-- Output Snipped --&gt;<br/>info: Installing rubygems dedicated to ruby-1.8.7-p302...<br/>&lt;-- Output Snipped --&gt;<br/>info: Installing ruby-1.9.2-head<br/>&lt;-- Output Snipped --&gt;<br/>info: Updating rubygems for /usr/local/rvm/gems/ruby-1.9.2-head<br/></div>


<div class="wp-terminal">$ rvm --default 1.9.2-head<br/>$ ruby -v<br/>$ ruby 1.9.2p0 (2010-08-18 revision 29034) [x86_64-linux]<br/><br/></div>

<p>Good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2010/08/25/how-to-install-rvm-on-ubuntu-10-04/feed/</wfw:commentRss>
		<slash:comments>78</slash:comments>
		</item>
		<item>
		<title>How to get non-model data in ActiveRecord Callbacks</title>
		<link>http://www.christopherirish.com/2010/08/16/how-to-get-non-model-data-in-activerecord-callbacks/</link>
		<comments>http://www.christopherirish.com/2010/08/16/how-to-get-non-model-data-in-activerecord-callbacks/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 08:34:54 +0000</pubDate>
		<dc:creator>Irish</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ActiveRecord]]></category>
		<category><![CDATA[Callbacks]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Thread]]></category>

		<guid isPermaLink="false">http://www.christopherirish.com/?p=427</guid>
		<description><![CDATA[On a project I&#8217;m currently working on, we use ActiveRecord callbacks heavily. From simplying creating other associated objects, to recording the historic activity about the object in question, and more. The drawback I find from the scope of AR callbacks though is that you only have direct access to data from the database. And since [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>On a project I&#8217;m currently working on, we use ActiveRecord callbacks heavily.  From simplying creating other associated objects, to recording the historic activity about the object in question, and more.  </p>
<p>The drawback I find from the scope of AR callbacks though is that you only have direct access to data from the database.  And since you can&#8217;t pass arguments to a AR callback, you can&#8217;t easily get the request params for example or know which controller action fired off the the AR chain that triggered the callback you&#8217;re in, or know who the current user logged in is.  </p>
<p>But it turns out that there is a way, however it is neither straight forward or obvious.  Say for example you have the following model and controller:</p>
<pre class="textmate-source sunburst"><span class='linenum'>    1</span> <span class="source source_ruby source_ruby_rails"><span class="meta meta_rails meta_rails_model"><span class="meta meta_class meta_class_ruby"><span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Post<span class="entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby"> <span class="punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby">&lt;</span> ActiveRecord::Base</span></span></span>
<span class='linenum'>    2</span>   <span class="support support_function support_function_activerecord support_function_activerecord_rails">belongs_to</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>user</span>
<span class='linenum'>    3</span>   <span class="support support_function support_function_activerecord support_function_activerecord_rails">belongs_to</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>group</span>
<span class='linenum'>    4</span>   <span class="support support_function support_function_activerecord support_function_activerecord_rails">has_one</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>alert</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>as</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>alertable<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span>
<span class='linenum'>    5</span>
<span class='linenum'>    6</span>   <span class="support support_function support_function_activerecord support_function_activerecord_rails">after_update</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>note_activity</span>
<span class='linenum'>    7</span>
<span class='linenum'>    8</span>   <span class="keyword keyword_other keyword_other_special-method keyword_other_special-method_ruby">private</span>
<span class='linenum'>    9</span>   <span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">note_activity</span></span>
<span class='linenum'>   10</span>     group<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>admins<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>each <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">admin</span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span>
<span class='linenum'>   11</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> What user is doing this update?
</span><span class='linenum'>   12</span>       admin<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>notifications<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>create<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_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>user</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>Someone<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='linenum'>   13</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_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>did something<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='linenum'>   14</span>     <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class='linenum'>   15</span>   <span class="keyword keyword_control keyword_control_ruby">end</span>
</span><span class='linenum'>   16</span> <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<pre class="textmate-source sunburst"><span class='linenum'>    1</span> <span class="source source_ruby source_ruby_rails"><span class="meta meta_rails meta_rails_controller"><span class="meta meta_class meta_class_ruby"><span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">Admin::PostsController<span class="entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby"> <span class="punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby">&lt;</span> ApplicationController</span></span></span>
<span class='linenum'>    2</span>
<span class='linenum'>    3</span>   <span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">update</span></span>
<span class='linenum'>    4</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>post</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> <span class="support support_class support_class_ruby">Post</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>params<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_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_section punctuation_section_array punctuation_section_array_ruby">]</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
<span class='linenum'>    5</span>
<span class='linenum'>    6</span>     <span class="keyword keyword_control keyword_control_ruby">if</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>post</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>update_attributes<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span>params<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_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>post</span><span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_ruby">]</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
<span class='linenum'>    7</span>       <span class="support support_function support_function_actionpack support_function_actionpack_rails">redirect_to</span> admin_posts_path
<span class='linenum'>    8</span>     <span class="keyword keyword_control keyword_control_ruby">else</span>
<span class='linenum'>    9</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>action</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>edit<span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_end punctuation_definition_string_end_ruby">'</span></span>
<span class='linenum'>   10</span>     <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class='linenum'>   11</span>   <span class="keyword keyword_control keyword_control_ruby">end</span>
</span><span class='linenum'>   12</span> <span class="keyword keyword_control keyword_control_ruby">end</span>
</pre>
<p>What we want to accomplish here is that all admins of a group get a notification when another admin user edits a post.  The post in question here has no context in it&#8217;s callback of which admin was logged in at the time the update happened.  So what we&#8217;re gonna do is put the admin user&#8217;s id onto the current thread of the request in a before filter.  Then, we&#8217;ll pull that id off in the callback to look up the admin and create the notifications.</p>
<p>So we&#8217;ll add a simple before filter:</p>
<pre class="textmate-source sunburst"><span class='linenum'>    1</span> <span class="source source_ruby source_ruby_rails"><span class="meta meta_rails meta_rails_controller"><span class="meta meta_class meta_class_ruby"><span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">ApplicationController<span class="entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby"> <span class="punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby">&lt;</span> ActionController::Base</span></span></span>
<span class='linenum'>    2</span>   <span class="support support_function support_function_actionpack support_function_actionpack_rails">before_filter</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>store_user</span>
<span class='linenum'>    3</span>
<span class='linenum'>    4</span>   <span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">store_user</span></span>
<span class='linenum'>    5</span>     <span class="support support_class support_class_ruby">User</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>current <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> current_user
<span class='linenum'>    6</span>   <span class="keyword keyword_control keyword_control_ruby">end</span>
</span><span class='linenum'>    7</span> <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>And create a couple class methods on User to store the currently logged in admin for the duration of the request:</p>
<pre class="textmate-source sunburst"><span class='linenum'>    1</span> <span class="source source_ruby source_ruby_rails"><span class="meta meta_rails meta_rails_model"><span class="meta meta_class meta_class_ruby"><span class="keyword keyword_control keyword_control_class keyword_control_class_ruby">class</span> <span class="entity entity_name entity_name_type entity_name_type_class entity_name_type_class_ruby">User<span class="entity entity_other entity_other_inherited-class entity_other_inherited-class_ruby"> <span class="punctuation punctuation_separator punctuation_separator_inheritance punctuation_separator_inheritance_ruby">&lt;</span> ActiveRecord::Base</span></span></span>
<span class='linenum'>    2</span>
<span class='linenum'>    3</span>   <span class="meta meta_function meta_function_method meta_function_method_with-arguments meta_function_method_with-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">self.current=</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">(</span><span class="variable variable_parameter variable_parameter_function variable_parameter_function_ruby">user</span><span class="punctuation punctuation_definition punctuation_definition_parameters punctuation_definition_parameters_ruby">)</span></span>
<span class='linenum'>    4</span>     <span class="support support_class support_class_ruby">Thread</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>current<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_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>user<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_array punctuation_section_array_ruby">]</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_ruby">=</span> user<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>try<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_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_section punctuation_section_function punctuation_section_function_ruby">)</span>
<span class='linenum'>    5</span>   <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class='linenum'>    6</span>
<span class='linenum'>    7</span>   <span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">self.current</span></span>
<span class='linenum'>    8</span>     <span class="variable variable_other variable_other_readwrite variable_other_readwrite_class variable_other_readwrite_class_ruby"><span class="punctuation punctuation_definition punctuation_definition_variable punctuation_definition_variable_ruby">@@</span>current</span> <span class="keyword keyword_operator keyword_operator_assignment keyword_operator_assignment_augmented keyword_operator_assignment_augmented_ruby">||=</span> <span class="support support_class support_class_ruby">User</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>find_by_id<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">(</span><span class="support support_class support_class_ruby">Thread</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>current<span class="punctuation punctuation_section punctuation_section_array punctuation_section_array_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>user<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_array punctuation_section_array_ruby">]</span><span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_ruby">)</span>
<span class='linenum'>    9</span>   <span class="keyword keyword_control keyword_control_ruby">end</span>
</span><span class='linenum'>   10</span> <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>Now we can alter our note_activity method in Post to get the admin who did the edit:</p>
<pre class="textmate-source sunburst"><span class='linenum'>    1</span> <span class="source source_ruby source_ruby_rails"><span class="meta meta_function meta_function_method meta_function_method_without-arguments meta_function_method_without-arguments_ruby"><span class="keyword keyword_control keyword_control_def keyword_control_def_ruby">def</span> <span class="entity entity_name entity_name_function entity_name_function_ruby">note_activity</span></span>
<span class='linenum'>    2</span>   group<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>admins<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>each <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">admin</span><span class="punctuation punctuation_separator punctuation_separator_variable punctuation_separator_variable_ruby">|</span>
<span class='linenum'>    3</span>     admin<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>notifications<span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>create<span class="punctuation punctuation_section punctuation_section_function punctuation_section_function_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>user</span> <span class="punctuation punctuation_separator punctuation_separator_key-value">=&gt;</span> <span class="support support_class support_class_ruby">User</span><span class="punctuation punctuation_separator punctuation_separator_method punctuation_separator_method_ruby">.</span>current<span class="punctuation punctuation_separator punctuation_separator_object punctuation_separator_object_ruby">,</span>
<span class='linenum'>    4</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_single string_quoted_single_ruby"><span class="punctuation punctuation_definition punctuation_definition_string punctuation_definition_string_begin punctuation_definition_string_begin_ruby">'</span>did something<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='linenum'>    5</span>   <span class="keyword keyword_control keyword_control_ruby">end</span>
<span class='linenum'>    6</span> <span class="keyword keyword_control keyword_control_ruby">end</span></span></pre>
<p>This works well in my project.  I&#8217;d like to know if there is a less &#8220;hacky&#8221; way of doing this but I&#8217;m not currently aware of one.</p>
<div id="hire" class="text-center">
  <a href="http://velocitylabs.io"><img src="http://www.christopherirish.com/wp-content/uploads/2018/07/velocity-labs-logo-text.png" alt="" title="velocity-labs-logo-text" width="300" class="alignleft size-full wp-image-971" /></a></p>
<p>
    Need web application development, maintenance for your existing app, or a third party code review?
  </p>
<p>
    <strong class="text-uppercase">Velocity Labs can help.</strong>
  </p>
<p>  <a href="http://velocitylabs.io#contact" class="btn btn-warning btn-block" target="_blank">Click here to get started!</a>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.christopherirish.com/2010/08/16/how-to-get-non-model-data-in-activerecord-callbacks/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
