<?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>Hank Beaver &#187; Rails</title>
	<atom:link href="http://www.hankbeaver.com/index.php/category/rails/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hankbeaver.com</link>
	<description>Open-source, Internet technologist who works for MaxMedia located in Atlanta, GA, USA</description>
	<lastBuildDate>Tue, 09 Aug 2011 18:20:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using Rails for custom applications and avoiding the CMS trap.</title>
		<link>http://www.hankbeaver.com/index.php/2009/09/03/using-rails-for-custom-applications-and-avoiding-the-cms-trap/</link>
		<comments>http://www.hankbeaver.com/index.php/2009/09/03/using-rails-for-custom-applications-and-avoiding-the-cms-trap/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 17:38:23 +0000</pubDate>
		<dc:creator>hbeaver</dc:creator>
				<category><![CDATA[CMS]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[esi]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[sinatra]]></category>

		<guid isPermaLink="false">http://www.rubyslacker.com/?p=102</guid>
		<description><![CDATA[I&#8217;m am still captivated by the perfect, simple CMS solution in Ruby/Rails (I&#8217;ll take another framework too).  There are some fantastic projects out there, browsercms.org for example. But posts like  THIS , really drive home the point. If Wordpress is so well suited for a simple site and/or blog, why not just use [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m am still captivated by the perfect, simple CMS solution in Ruby/Rails (I&#8217;ll take another framework too).  There are some fantastic projects out there, <a href="http://www.rubyslacker.com/wp-admin/browsercms.org">browsercms.org</a> for example. But posts like <a href="http://aaronlongwell.com/2009/06/the-ruby-on-rails-cms-dilemma.html"> THIS </a>, really drive home the point. If Wordpress is so well suited for a simple site and/or blog, why not just use it? <a href="http://www.igvita.com/2007/07/04/integrating-wordpress-and-rails/">Igvita</a> demonstrates easy Rails integration with <a href="http://www.apache.org">Apache</a> rewrite rules.</p>
<p>There are others out there stating the same thing: while Rails can be used to create a CMS, a developer&#8217;s time is better spent solving business rather than reinventing the wheel in Ruby to keep the whole project/code under one umbrella. And at my current gig, we are starting to retool for this paradigm. Rails and <a href="http://www.sinatrarb.org">Sinatra</a> apps are purely business focuses and super light weight. These service applications can them be glued together via <a href="http://www.w3.org/TR/esi-lang">ESI</a>, rewrites, or Wordpress for consumption. In effect, your complex web app is assembled at request time from a set of simple web services. Here is some mock code to demonstrate:</p>
<pre>
wordpress_template.php
//some more wonder wordpress stuff
&lt;?= include_rails_service('http://service.app/user/profile',ESI_INCLUDE) ?&gt;
//some more wonder wordpress stuff
&lt;?= include_rails_service('http://service.app2/events/weeks/2',SERVICE) ?&gt;
//end of wordpress.php
...
//function included elsewhere
function include_rails_service(service_url,type){
//could return any of following for the resource url
 switch (type) {
  case ESI_INCLUDE:
   return "&lt;esi include ='" + service_url + "'&gt;";
   break;
  case SERVICE:
   include service_url;
   break;
  case AJAX:
//javascript include with service js, doing doc.write
}
}
</pre>
<p>The point is Wordpress doesn&#8217;t know about Rails and Rails doesn&#8217;t know about Wordpress. Keep them seperate, keep them simple and make life better.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hankbeaver.com/index.php/2009/09/03/using-rails-for-custom-applications-and-avoiding-the-cms-trap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debugging/Troubleshooting Rails Applications in Production Enviroments</title>
		<link>http://www.hankbeaver.com/index.php/2009/05/29/debuggingtroubleshooting-rails-applications-in-production-enviroments/</link>
		<comments>http://www.hankbeaver.com/index.php/2009/05/29/debuggingtroubleshooting-rails-applications-in-production-enviroments/#comments</comments>
		<pubDate>Fri, 29 May 2009 22:55:37 +0000</pubDate>
		<dc:creator>hbeaver</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[production]]></category>

		<guid isPermaLink="false">http://www.rubyslacker.com/?p=84</guid>
		<description><![CDATA[Introduction
At my current gig with Primedia, we have some pretty high volume Rails sites. Since having highly available sites are essential for our core business, we have to be very attentive to production issues. Below is a list that I&#8217;ve compiled recently in my head and by working with some very bright folks. This doc [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>At my current gig with <a href="http://www.primedia.com">Primedia</a>, we have some pretty high volume Rails sites. Since having highly available sites are essential for our core business, we have to be very attentive to production issues. Below is a list that I&#8217;ve compiled recently in my head and by working with some very bright folks. This doc is to help Ops/Dev remember some basics and tricks when debugging issues. So remember to try this stuff.</p>
<p><strong>Non-Technical (READ FIRST)</strong></p>
<p>1. If the issue is not a major impact on production, make sure all your troubleshooting is passive! You might introduce an outage if you try serious troubleshooting.<br />
2. Confirm the issue with Ops/Infrastructure in your presence, this gets buy-in from with the folks who have official root access.<br />
3. As a developer, you should not work alone on production systems except to gather information (if you get temporary access). All changes (in seeking issue mitigation) should be paired with Ops/Infra. This will avoid finger-pointing and headaches later.</p>
<p><strong>Technical</strong></p>
<p>Elimination + log files is my troubleshooting method of choice.</p>
<p>1. Skip the load balancer if possible and hit direct IP/Port of a single app server to eliminate load balancer in mix.<br />
2. Enable DEBUG log level and restart app server(s). Preferably, take an app server out of load balancer pool and work on in isolation. Regardless, DEBUG can slow response signficantly so be aware. However, there are situations where DEBUG is the only way to get an indication from Rails what is going on.<br />
3. Tail log file of single app IP/Port to squelch noise from other servers and hit just that app server.<br />
4. Make sure that the PIDs are not hung,old versions. Look at time/date of PIDS. If the deploy is screwed up, you can be deploying new code and yet the processes running are code from a month ago.<br />
5. To be thorough, look at the kernel logs too. In Linux, /var/log/messages etc. You could have something else that is going on.<br />
6. The logs should give status regarding database(s), but especially look for the words &#8220;timeout&#8221; if you have any custom network libraries that fetch data (we do) or &#8220;ActiveRecord&#8221;.  Perhaps even, grep for it.<br />
7. Use a non-browser client, like Curl or wget to eliminate possible browser issues. Case in point, we had an issue related to ActiveRecord sessions that were migrated to another datacenter. When accessed via Curl there was no issue (Curl does not save cookies by default).</p>
<p><strong>Other</strong></p>
<p>1. If you cannot duplicate issue in development, remember to change your configs to look like production mode and run your development workstation in production mode. Rails behaves different in its modes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hankbeaver.com/index.php/2009/05/29/debuggingtroubleshooting-rails-applications-in-production-enviroments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New favorite tool in toolbox for web development: Charles Web Debugging Proxy</title>
		<link>http://www.hankbeaver.com/index.php/2008/12/19/new-favorite-tool-in-toolbox-for-web-development-charles-http-web-proxy/</link>
		<comments>http://www.hankbeaver.com/index.php/2008/12/19/new-favorite-tool-in-toolbox-for-web-development-charles-http-web-proxy/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 15:41:21 +0000</pubDate>
		<dc:creator>hbeaver</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[software design]]></category>
		<category><![CDATA[charles http proxy web development sniffer .net rails r]]></category>

		<guid isPermaLink="false">http://www.rubyslacker.com/?p=73</guid>
		<description><![CDATA[I will not regurgitate what Charles&#8217; website can already tell you. Charles is a great tool. Moreover, let me add some obvious points for people like myself:

It runs on OSX and quickly.
It is affordable (we are getting licenses here this week)
It has TONS of features (especially allowing filtering of anything in URL)
It auto-magically acts a [...]]]></description>
			<content:encoded><![CDATA[<p>I will not regurgitate what <a href="http://www.charlesproxy.com/">Charles&#8217; website</a> can already tell you. Charles is a great tool. Moreover, let me add some obvious points for people like myself:</p>
<ul>
<li>It runs on OSX and quickly.</li>
<li>It is affordable (we are getting licenses here this week)</li>
<li>It has TONS of features (especially allowing filtering of anything in URL)</li>
<li>It auto-magically acts a HTTP Proxy after reboot when Charles is started on ALL HTTP based applications.</li>
</ul>
<p>Why you may ask not use <a title="http://getfirebug.com/" href="http://getfirebug.com/">Firebug</a>, it&#8217;s free!</p>
<p>If you are doing Javascript work and trying to naildown activity on the wire (outside of the browser), you have to rely on a proxy or sniffer, especially if you are testing many browsers at once. The heavyweight option is indeed to use <a title="WireShark" href="http://www.wireshark.org">Wireshark</a> on OSX, like I initially did. But this can add complexity when you are under a deadline.</p>
<p>Also, Firebug has soooo many great features I need to use concurrently, having a good proxy monitor allows me to use Firebugs other incredible features in tandem.</p>
<p>Last week I had such deadlines at my paid gig rewriting a<a title="www.microsoft.com/net" href="http://www.rubyslacker.com/wp-admin/www.microsoft.com/net"> .NET</a><a title="www.microsoft.com/net" href="http://www.rubyslacker.com/wp-admin/www.microsoft.com/net"> 3.5</a> site into <a title="http://www.rubyonrails.org/" href="http://www.rubyonrails.org/">Rails 2.1.2</a> . I had to (in a hurry) integrate a slew of user/tracking Javascript events that fired off GET requests to an external site. The query string and/or request HAD to include the variables exactly to ensure our internal datawarehouses didn&#8217;t get borked. Secondly, integrating the tags had to NOT break existing AJAX functionality surrounding the same buttons and links.</p>
<p>Using Firebug to monitor the happiness of Javascript, investigate the DOM and use the console to query, took up most of the Firebug interface and time. Having Charles running in a separate monitor (with the required URLS filtered) made for much,much quicker development and debugging.</p>
<p>Take a look at this example call (notice the Filter line that has part of the host addres). This GET request was fired when a user click a button. Charles verified the request had all the key/value pairs expected: <a href="http://www.rubyslacker.com/wp-content/uploads/2008/12/picture-7.png"><img class="aligncenter size-medium wp-image-74" title="Charles Sequence Filter" src="http://www.rubyslacker.com/wp-content/uploads/2008/12/picture-7-300x135.png" alt="" width="300" height="135" /></a></p>
<p>Using Charles and Firebug together rounds out Frontend web development, in my case using Rails 2.1.2 and JQuery, and helps keep your velocity up.</p>
<p>Lastly, there are features I have not even explored with Charles. I applaud the guys from Charles for writing such a great tool that saved my week and sanity.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hankbeaver.com/index.php/2008/12/19/new-favorite-tool-in-toolbox-for-web-development-charles-http-web-proxy/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Notes on MerbDay Atlanta 2008</title>
		<link>http://www.hankbeaver.com/index.php/2008/12/07/notes-on-merbday-atlanta-2008/</link>
		<comments>http://www.hankbeaver.com/index.php/2008/12/07/notes-on-merbday-atlanta-2008/#comments</comments>
		<pubDate>Mon, 08 Dec 2008 00:48:37 +0000</pubDate>
		<dc:creator>hbeaver</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.rubyslacker.com/?p=68</guid>
		<description><![CDATA[Ironically, the two most interesting items for me personally were not directory related to Merb at all. I was quite impressed with the CSS capabilities of SASS and CouchDB gave me hope that being stuck in the rigidity of columns in SQL is not always my path. Here&#8217;s my my Merbday summary,  iteration retrospective format:
STOP:

 [...]]]></description>
			<content:encoded><![CDATA[<p>Ironically, the two most interesting items for me personally were not directory related to <a title="http://merbivore.com/" href="http://merbivore.com/">Merb</a> at all. I was quite impressed with the CSS capabilities of <a title="http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html" href="http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html">SASS</a> and <a title="incubator.apache.org/couchdb/" href="http://www.rubyslacker.com/wp-admin/incubator.apache.org/couchdb">CouchDB</a> gave me hope that being stuck in the rigidity of columns in SQL is not always my path. Here&#8217;s my my Merbday summary,  iteration retrospective format:</p>
<p>STOP:</p>
<ul>
<li> Assuming Merb is &#8220;fragmentation&#8221; (so said someone smarter than me ) of the Rails community and a real effort to improve on Ruby as the defacto web programming language.</li>
</ul>
<p>START:</p>
<ul>
<li> Using <a title="http://ruby-prof.rubyforge.org/" href="http://ruby-prof.rubyforge.org/">ruby-prof</a> in Rails projects and <a title="http://cfis.savagexi.com/2007/07/10/how-to-profile-your-rails-application" href="http://cfis.savagexi.com/2007/07/10/how-to-profile-your-rails-application">Kcachegrind</a> to profile apps. (thanks for <a title="http://yehudakatz.com/" href="http://yehudakatz.com/">Yehuda Katz</a> at <a title="www.engineyard.com " href="http://www.rubyslacker.com/wp-admin/www.engineyard.com ">www.engineyard.com </a>)</li>
<li> Playing with Merb on a real project and focus on understand slices and interaction with other slices.</li>
<li> Investigate writing an Admin or basic CMS slice with someone else.</li>
</ul>
<p>CONTINUE:</p>
<ul>
<li>Loving Rails and not abandon it as yet.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.hankbeaver.com/index.php/2008/12/07/notes-on-merbday-atlanta-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using gem dependencies with Rspec == BAD ! !</title>
		<link>http://www.hankbeaver.com/index.php/2008/11/17/using-gem-dependencies-with-rspec-bad/</link>
		<comments>http://www.hankbeaver.com/index.php/2008/11/17/using-gem-dependencies-with-rspec-bad/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 17:29:42 +0000</pubDate>
		<dc:creator>hbeaver</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Rspec]]></category>
		<category><![CDATA[exceptions]]></category>
		<category><![CDATA[gems]]></category>

		<guid isPermaLink="false">http://1000fires.com/wordpress/?p=51</guid>
		<description><![CDATA[We had an issue the last couple of weeks on a new Rails project we started here at my gig. All Rails exceptions were quietly logged without showing any stack trace to browser. This was very annoying. Secondly, the RAILS_ENV was reported as &#8220;test&#8221;. mmmm, very suspicious. After some investigation I found the culprit on [...]]]></description>
			<content:encoded><![CDATA[<p>We had an issue the last couple of weeks on a new Rails project we started here at my gig. All Rails exceptions were quietly logged without showing any stack trace to browser. This was very annoying. Secondly, the RAILS_ENV was reported as &#8220;test&#8221;. mmmm, very suspicious. After some investigation I found the culprit on rails.rb line #1 of rails-rspec gem installed in our vendor dir:</p>
<div class="code">silence_warnings { RAILS_ENV = &#8220;test&#8221; }</div>
<p>Take a look at this to get a little context:</p>
<p>http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies</p>
<p>How can rspec affect your actual Rails environment, script/server, script/console, script/about? I&#8217;ll show you. enter our environment.rb:</p>
<div class="code">
<p>config.gem &#8216;rspec-rails&#8217;,<br />
:version =&gt; &#8216;&gt;= 1.1.11&#8242;, :lib =&gt; &#8217;spec/rails&#8217;<br />
config.gem &#8216;rspec&#8217;,<br />
:version =&gt; &#8216;&gt;= 1.1.11&#8242;, :lib =&gt; &#8217;spec&#8217;</p>
</div>
<p>Aha! So effectively, by including our gems here too (and gaining the added benefits noted above at ryandaigle.com )rather than simply in our spec_helper, we replaced our RAILS_ENV and invoked the Rails equivalent of an exception black hole.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hankbeaver.com/index.php/2008/11/17/using-gem-dependencies-with-rspec-bad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My passenger config example.</title>
		<link>http://www.hankbeaver.com/index.php/2008/09/17/my-passenger-config-example/</link>
		<comments>http://www.hankbeaver.com/index.php/2008/09/17/my-passenger-config-example/#comments</comments>
		<pubDate>Wed, 17 Sep 2008 17:22:56 +0000</pubDate>
		<dc:creator>hbeaver</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[config]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[passenger]]></category>

		<guid isPermaLink="false">http://1000fires.com/wordpress/?p=44</guid>
		<description><![CDATA[Passenger (a.k.a mod_rails) is getting some buzz (google it). Looking at the below config and the fact that deployments are automatic from Web Server with a simple file touch.
In http.conf:
LoadModule passenger_module /usr/lib64/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-2.0.3
PassengerRuby /usr/bin/ruby
&#60;VirtualHost *:80&#62;
ServerName vwebadm11.atlis1
#DocumentRoot /var/www/apps/html
DocumentRoot /var/www/apps/provisioning_webservices/current/public
ErrorLog logs/prodops_errors_log
CustomLog logs/prodops_log combined
#RailsBaseURI /prov_websvc         # Passenger Rails link
RailsEnv test
&#60;/VirtualHost&#62;
&#60;Directory "/var/www/apps/provisioning_webservices/current/public"&#62;
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
&#60;/Directory&#62;
]]></description>
			<content:encoded><![CDATA[<p>Passenger (a.k.a mod_rails) is getting some buzz (google it). Looking at the below config and the fact that deployments are automatic from Web Server with a simple file touch.</p>
<p>In http.conf:</p>
<pre>LoadModule passenger_module /usr/lib64/ruby/gems/1.8/gems/passenger-2.0.3/ext/apache2/mod_passenger.so
PassengerRoot /usr/lib64/ruby/gems/1.8/gems/passenger-2.0.3
PassengerRuby /usr/bin/ruby</pre>
<pre>&lt;VirtualHost *:80&gt;
ServerName vwebadm11.atlis1
#DocumentRoot /var/www/apps/html
DocumentRoot /var/www/apps/provisioning_webservices/current/public
ErrorLog logs/prodops_errors_log
CustomLog logs/prodops_log combined
#RailsBaseURI /prov_websvc         # Passenger Rails link
RailsEnv test
&lt;/VirtualHost&gt;</pre>
<pre>&lt;Directory "/var/www/apps/provisioning_webservices/current/public"&gt;
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
&lt;/Directory&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hankbeaver.com/index.php/2008/09/17/my-passenger-config-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calling initialize in ActiveRecord model causes nil.has_keys? error.</title>
		<link>http://www.hankbeaver.com/index.php/2008/09/02/calling-initialize-in-activerecord-model-causes-nilhas_keys-error/</link>
		<comments>http://www.hankbeaver.com/index.php/2008/09/02/calling-initialize-in-activerecord-model-causes-nilhas_keys-error/#comments</comments>
		<pubDate>Tue, 02 Sep 2008 13:24:35 +0000</pubDate>
		<dc:creator>hbeaver</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[has_keys?]]></category>
		<category><![CDATA[model]]></category>

		<guid isPermaLink="false">http://1000fires.com/wordpress/?p=43</guid>
		<description><![CDATA[When instantiating a model class this error occurs:
instance = MyModel.new
NoMethodError: You have a nil object when you didn't expect it!
The error occurred while evaluating nil.has_key?
This is rectified by placing a super within model class.
def initialize
super
logger.debug("initialize VirtualMta: #{self.class}")
end
]]></description>
			<content:encoded><![CDATA[<p>When instantiating a model class this error occurs:</p>
<pre>instance = MyModel.new</pre>
<pre>NoMethodError: You have a nil object when you didn't expect it!</pre>
<pre>The error occurred while evaluating nil.has_key?</pre>
<p>This is rectified by placing a <strong>super</strong> within model class.</p>
<pre>def initialize</pre>
<pre>super</pre>
<pre>logger.debug("initialize VirtualMta: #{self.class}")</pre>
<pre>end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hankbeaver.com/index.php/2008/09/02/calling-initialize-in-activerecord-model-causes-nilhas_keys-error/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mixin Module Madness &#8212; why self ain&#8217;t really self</title>
		<link>http://www.hankbeaver.com/index.php/2008/04/01/mixin-module-madness-why-self-aint-really-self/</link>
		<comments>http://www.hankbeaver.com/index.php/2008/04/01/mixin-module-madness-why-self-aint-really-self/#comments</comments>
		<pubDate>Tue, 01 Apr 2008 20:11:15 +0000</pubDate>
		<dc:creator>hbeaver</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[self Rails introspection meta]]></category>

		<guid isPermaLink="false">http://1000fires.com/wordpress/?p=39</guid>
		<description><![CDATA[This all came up b/c I wanted to write a shared mixin module to have attachment_fu ready actions for all my controllers that have attachments. No need to put that crap in every controller. So in a mixin module when you want to do some fun reflection/introspection like so:
&#8230;
    @this_obj = self.controller_name.classify.constantize.find_safe
(id,logged_in_user.id)
&#8230;
In [...]]]></description>
			<content:encoded><![CDATA[<p>This all came up b/c I wanted to write a shared mixin module to have attachment_fu ready actions for all my controllers that have attachments. No need to put that crap in every controller. So in a mixin module when you want to do some fun reflection/introspection like so:</p>
<p>&#8230;</p>
<pre>    @this_obj = self.controller_name.classify.constantize.find_safe
(id,logged_in_user.id)</pre>
<p>&#8230;</p>
<p>In Dev this worked great. Tests were good, my mostly view/template developer partner, approved. Deploy to test and WHAMMO!</p>
<p>&#8230;</p>
<pre>    "NameError ("Blogs | ListAll" is not a valid constant name!):</pre>
<p>&#8230;&#8221;</p>
<p>What gives? Mmm, seems when you include a mixin, that is included in a controller. The self.controller_name will report incorrectly in Test and Prod. So I had to adjust the code a little using a new method:</p>
<pre>        @this_obj = self.this_controller_name.classify.constantize.find_safe(
id,logged_in_user.id)</pre>
<p>Below is the method(which is basically David&#8217;s code for controller_name).</p>
<pre>###############################</pre>
<pre>#This method is here b/c it is apparent that Rails
#ActionController.controller_name</pre>
<pre># is unreliable in Test and Production for some reason.</pre>
<pre># attachment_symbol_name: Blogs | List_all_attachments</pre>
<pre># attachment_model ERROR: "Blogs | ListAllAttachment"
#is not a valid constant name</pre>
<pre>###############################</pre>
<pre>def this_controller_name</pre>
<pre>    self_class = self.class.to_s.sub(/Controller$/, '').underscore</pre>
<pre>end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hankbeaver.com/index.php/2008/04/01/mixin-module-madness-why-self-aint-really-self/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subversion error &#8216;containing working copy admin area is missing&#8217; when generating Rails doc&#8230;</title>
		<link>http://www.hankbeaver.com/index.php/2008/02/23/subversion-error-containing-working-copy-admin-area-is-missing-when-generating-rails-doc/</link>
		<comments>http://www.hankbeaver.com/index.php/2008/02/23/subversion-error-containing-working-copy-admin-area-is-missing-when-generating-rails-doc/#comments</comments>
		<pubDate>Sat, 23 Feb 2008 21:57:29 +0000</pubDate>
		<dc:creator>hbeaver</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[subversion]]></category>

		<guid isPermaLink="false">http://1000fires.com/wordpress/?p=34</guid>
		<description><![CDATA[This error is extremely frustrating. It occurs when the .svn info is missing in a directory. In my example this happens when running &#8216;rake doc:app&#8217;  and I have found only one sequence that will fix this. In my case, I am removing doc from subversion and going to manage outside of source control.
To fix:

cd /doc/app
mv [...]]]></description>
			<content:encoded><![CDATA[<p>This error is extremely frustrating. It occurs when the .svn info is missing in a directory. In my example this happens when running &#8216;rake doc:app&#8217;  and I have found only one sequence that will fix this. In my case, I am removing doc from subversion and going to manage outside of source control.</p>
<p>To fix:</p>
<ol>
<li>cd <RAILS_HOME>/doc/app</li>
<li>mv &#8216;app&#8217; &#8216;app-todelete&#8217;</li>
<li>do a new checkout from svn just on the directory you renamed. Like so:<br />
svn co svn+ssh://usery@mysecre.server.com/var/www/apps/repos/trunk/doc/app</li>
<li>The newest version in source should be in the proper location.</li>
<li>You will unfortunately have to merge any changes from the old directory, as in my case &#8216;app-todelete&#8217;</li>
</ol>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hankbeaver.com/index.php/2008/02/23/subversion-error-containing-working-copy-admin-area-is-missing-when-generating-rails-doc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>has_many associations, using in helper tag and a little about blocks.</title>
		<link>http://www.hankbeaver.com/index.php/2008/02/10/has_many-associations-using-in-helper-tag-and-a-little-about-blocks/</link>
		<comments>http://www.hankbeaver.com/index.php/2008/02/10/has_many-associations-using-in-helper-tag-and-a-little-about-blocks/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 20:47:43 +0000</pubDate>
		<dc:creator>hbeaver</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[block]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[helper tags]]></category>

		<guid isPermaLink="false">http://1000fires.com/wordpress/?p=31</guid>
		<description><![CDATA[Soon the rest of this blog will deal with a basic overview of has_many associations and a practical use. For now look at this simple tag that uses has_many of a Blog model to show the Interests (or topics) for a given blog. You would use this helper_tag like so in your view, given that [...]]]></description>
			<content:encoded><![CDATA[<p>Soon the rest of this blog will deal with a basic overview of has_many associations and a practical use. For now look at this simple tag that uses has_many of a Blog model to show the Interests (or topics) for a given blog. You would use this helper_tag like so in your view, given that you have a single instance of a blog object called ‘blog’</p>
<p><%= more_ugly_interests_tag(blog) %></p>
<p>I hope this small article might help others:</p>
<pre>
#########################################
#Tag to show usage of has_many for a model.
#Ruby on Rails
#*this_model* is the actual instance of a blog or photo
#which has a list of interests.
#
#Call tag like this:
# <%= more_ugly_interests_tag(blog) %>
#the syntax below uses what Ruby calls a 'block'
#this is the format:
# some_variable_that_has_a_list.each { |list_item
# #do something with each item
# puts list_item + " !!!!"
# }
#########################################
def more_ugly_interests_tag(this_model)

to_return = "INTERESTS"

this_model.interests.each { |each_interest|

to_return =  << each_interest << "
"

}

#now we have end the whole function/method with what we want to return/print
to_return

end</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.hankbeaver.com/index.php/2008/02/10/has_many-associations-using-in-helper-tag-and-a-little-about-blocks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

