<?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>Codedrop™ Weblog &#187; Rails</title>
	<atom:link href="http://www.codedrop.ca/blog/archives/tag/rails/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codedrop.ca/blog</link>
	<description>Drop'n some code and other tech tidbits...</description>
	<lastBuildDate>Mon, 26 Jul 2010 16:45:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Dynamic fields in YAML file.</title>
		<link>http://www.codedrop.ca/blog/archives/68</link>
		<comments>http://www.codedrop.ca/blog/archives/68#comments</comments>
		<pubDate>Mon, 26 Jan 2009 21:30:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.codedrop.ca/blog/?p=68</guid>
		<description><![CDATA[Recently I had the need to setup environment specific .yml files for email configuration.  Normally this goes off without a hitch, however in my case I had the additional requirement of being able to dynamically substitute values in the yml file at runtime.   I thought it would be nice to allow configuration of email to, [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I had the need to setup environment specific .yml files for email configuration.  Normally this goes off without a hitch, however in my case I had the additional requirement of being able to dynamically substitute values in the yml file at runtime.   I thought it would be nice to allow configuration of email to, cc, bcc, subject and so forth through the yml file&#8230; thus allowing different environments to target different recipients.  I first tried to access the model from the yml file&#8230;</p>
<p><code><br />
recipient: &lt;%= user.email_address %&gt;<br />
</code></p>
<p>but to no avail.  Seems like the mailer was loaded before the model so the user object was not yet available.  A solution that I came up with, though kind of hacky, was to tokenize the yml with placeholders that are dynamically replaced by the mailer at runtime.</p>
<p>My .yml file now looks like this:</p>
<p><code><br />
email_notifications:<br />
activate:<br />
from: acct_activations@company.com<br />
recipients: @USER_EMAIL@<br />
bcc: devuser@company.com<br />
subject: Activate your new account (@USER_COMPANY@)<br />
</code></p>
<p>and in my mailer I added a method to do the replacement:</p>
<p><code> def replace_yaml_tokens(yaml_doc, user)<br />
yaml_obj = YAML::dump( yaml_doc )<br />
yaml_obj.gsub!(/\@USER_EMAIL\@/, user.email_address)<br />
yaml_obj.gsub!(/\@USER_COMPANY\@/, user.company)<br />
YAML::load( yaml_obj )<br />
end<br />
</code></p>
<p>finally it was a simple call after initializing the mailer to do the replacement.<br />
<code><br />
mailer=replace_yaml_tokens(YAML::load( File.open( "#{RAILS_ROOT}/config/activation.yml" ) )['email_notifications']['activate'], user);<br />
</code></p>
<p>Like I said, maybe not the best solution, but one that worked for me!</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Dynamic+fields+in+YAML+file.+http://pfp6f.th8.us" title="Post to Twitter"><img class="nothumb" src="http://www.codedrop.ca/blog/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Dynamic+fields+in+YAML+file.+http://pfp6f.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codedrop.ca/blog/archives/68/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails rake tests randomly generate ORA-12520 errors.</title>
		<link>http://www.codedrop.ca/blog/archives/58</link>
		<comments>http://www.codedrop.ca/blog/archives/58#comments</comments>
		<pubDate>Mon, 05 Jan 2009 22:07:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://www.codedrop.ca/blog/?p=58</guid>
		<description><![CDATA[If you find your application randomly throwing &#8220;ORA-12520: TNS:listener could not find available handler for requested type of server&#8221; errors, then try to increase the number of available processes that you have allocated to your Oracle instance.
Logon to
Oracle using sys as sysdba and execute the following:
ALTER SYSTEM SET PROCESSES=150 SCOPE=SPFILE;
After changing the PROCESSES parameter restart [...]]]></description>
			<content:encoded><![CDATA[<p>If you find your application randomly throwing &#8220;ORA-12520: TNS:listener could not find available handler for requested type of server&#8221; errors, then try to increase the number of available processes that you have allocated to your Oracle instance.</p>
<p>Logon to<br />
Oracle using sys as sysdba and execute the following:</p>
<p><code>ALTER SYSTEM SET PROCESSES=150 SCOPE=SPFILE;</code></p>
<p>After changing the PROCESSES parameter restart your Oracle service.  I recently encountered this on a rails project I&#8217;m currently working on with an Oracle XE installation running in a Windows XP VM.  It seems like the default process level was set to 40 so running the rake tests consistently, but sporadically produced these errors at random intervals.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=Rails+rake+tests+randomly+generate+ORA-12520+errors.+http://dm3qd.th8.us" title="Post to Twitter"><img class="nothumb" src="http://www.codedrop.ca/blog/wp-content/plugins/tweet-this/icons/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Rails+rake+tests+randomly+generate+ORA-12520+errors.+http://dm3qd.th8.us" title="Post to Twitter">Tweet This Post</a></p>]]></content:encoded>
			<wfw:commentRss>http://www.codedrop.ca/blog/archives/58/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
