<?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>Technical Notes &#187; Ruby</title>
	<atom:link href="http://blog.anthonychaves.net/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.anthonychaves.net</link>
	<description>Life is software and jujitsu</description>
	<lastBuildDate>Tue, 16 Feb 2010 22:15:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Dummy Code (Quick&#8217;n&#039;Dirty vs. Engineered)</title>
		<link>http://blog.anthonychaves.net/2009/02/04/dummy-code-quickndirty-vs-engineered/</link>
		<comments>http://blog.anthonychaves.net/2009/02/04/dummy-code-quickndirty-vs-engineered/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 22:34:13 +0000</pubDate>
		<dc:creator>Anthony Chaves</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[career]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://blog.anthonychaves.net/?p=125</guid>
		<description><![CDATA[When creating software, two people will never write the same implementation of a method or system of non-trivial design.  Creating software is a problem solving process and there are usually many ways to solve one problem.  The solutions may differ in elegance and efficiency while giving the same output for a given set of inputs.  [...]]]></description>
			<content:encoded><![CDATA[<p>When creating software, two people will never write the same implementation of a method or system of non-trivial design.  Creating software is a problem solving process and there are usually many ways to solve one problem.  The solutions may differ in elegance and efficiency while giving the same output for a given set of inputs.  A correct solutions is a correct solution regardless of implementation.<span id="more-125"></span></p>
<p>Building software modules within a team requires communicating, at a minimum,  method or class signatures and a general idea of the functionality.  This may include a detailed design document clearly specifying method signature and a pseudo-code implementation or method stubs and comments about what the method should do right in the source file.  One thing that should never be used for communicating a signature and functionality is dummy code.</p>
<p>Dummy code looks like real code.  It is real code but it rarely works.  Even if it compiles it doesn&#8217;t produce the correct result when run.  Nor are there any tests that prove it (in)correct.  Dummy code exists only for the sake of its author&#8217;s gratification.</p>
<p>Rather than talk about the desired functionality through some more productive means the dummy code author thinks he is helpfully providing a guesstimate of correct implementation.  What he has actually done is provide a jumbled mess of non-working code cleverly disguised as a working part of the project when he checks it in to the SCM.  The dummy code author thinks someone else will come along and provide the correct implementation &#8220;later&#8221;.</p>
<p>What he doesn&#8217;t realize is that his dummy code is almost indistinguishable from code that should be part of the project.  The next person to try to reuse this code is in for hours of WTF moments trying to figure out WTF the code is supposed to do and why it&#8217;s got code branching five levels deep.</p>
<p>At my first post-college job I had a wonderful mentor.  Thys (pronounced <em>Tays</em>, like &#8220;taste&#8221; without the second &#8216;t&#8217;) and I were talking one day when he asked me a question.  &#8220;Anthony, if you were given a task of writing software that would only be run once would you do it quick-and-dirty or with a well-measured, engineered approach?&#8221;</p>
<p>How bad could &#8220;quick-and-diry&#8221; be if the software would run only once?  I thought about it for a moment before answering.  Quick and dirty.</p>
<p>Thys said he would never write quick and dirty software.  Doing so figuratively creates a  monkey on the developerment team&#8217;s back.  The software that only needs to run once inevitably needs to run a second time and a third time and eventually run regularly.  Thys helped me realize that software evolves and escapes.  Useful software will run indefinitely.  Any time and effort saved on the initial write will be lost 10 times (I made that number up.  It is actually higher.  Any want to provide real data or examples?) over on the maintenance, bug fixes and rewrites.</p>
<p>Writing dummy code is writing software quick and dirty without any idea of the implementation details.  Bad code and bad algorithms.  The worst of both worlds.  It&#8217;s been a long time since Thys and I had that conversation but the years have proven him right again and again.  Any code worth checking in to SCM is worth writing well.  That includes unit tests.</p>
<p>Dummy code has no place in SCM.  If you&#8217;re not going to correctly implement a method you stub out then don&#8217;t provide an implementation at all.  Leave some comments around the method stub if you have to.  Open a ticket in the issue tracking system to let someone know the method needs an implementation and describe the input and output.  Let the implementer determine which algorithms and data structures to use.</p>
<p>Dummy code is a hazard to software projects.  It violates the principle of least astonishment.  Next time you think about writing some remember that the next person that uses the code will waste time figuring out why it doesn&#8217;t work as expected.</p>
<p>If you check code in to your SCM where other people can pull it, take a look at what you&#8217;re checking in.  Does it work?  Does it work well?  Are there tests that prove it?  Helping someone by coding less is sometimes the best help of all.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anthonychaves.net/2009/02/04/dummy-code-quickndirty-vs-engineered/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Industry Ignorance</title>
		<link>http://blog.anthonychaves.net/2009/01/22/industry-ignorance/</link>
		<comments>http://blog.anthonychaves.net/2009/01/22/industry-ignorance/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 22:27:41 +0000</pubDate>
		<dc:creator>Anthony Chaves</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[scalability]]></category>

		<guid isPermaLink="false">http://blog.anthonychaves.net/?p=106</guid>
		<description><![CDATA[Today I let out a dejected sigh after reading a response to my latest post on the Joel on Software message board.  My post was just a reminder about the BostonScalability User Group meeting that takes place next Wednesday the 28th.  I post the meeting announcements on JoS and a good number of people hear [...]]]></description>
			<content:encoded><![CDATA[<p>Today I let out a dejected sigh after reading a response to my latest post on the Joel on Software message board.  My post was just a reminder about the BostonScalability User Group meeting that takes place next Wednesday the 28th.  I post the meeting announcements on JoS and a good number of people hear about the meetings from the JoS board.  Every month a few new people tell me they found the group through JoS.  So why did I sigh after reading the response to the meeting reminder?</p>
<p><span id="more-106"></span>I don&#8217;t make any money running the group.  In fact it costs me money.  I do a good amount of planning, coordinating, buying, booking and raffle prize finding for the group.  I love seeing 30+ people show up for our after work meetings.   It&#8217;s a lot of work but I do it because I am passionate about emerging trends in application scalability.  It&#8217;s a labor of love that I find professionally and personally rewarding.  Like all good geeks I maintain a healthy hobby writing software outside business hours.</p>
<p>I&#8217;m interested in building bigger, better software.  Batch applications, database interactions, web applications, CPU intensive algorithims should be as effective as possible.  Effective does not necessarily mean efficient.  Effectiveness is based on price, time-to-market, performance, maintenance cost, etc.  Analyzing these facets is important. The tools used to arrive at the solution are important, too.</p>
<p>BostonSUG has wonderful speakers who generously donate their time to speak at our meetings.  These people come in from all over the country.  Just a few examples, we&#8217;ve hosted Orion Letizi and Nikita Ivanov from San Francisco, Billy Newport from Minnesota and Mike Culver from Washington.  We&#8217;ve had numerous local speakers who we appreciate just as much as those that fly to see us.  Patrick Peralta, Tom O&#8217;Hare and Rakesh Chaudhary had large audiences.  Each of these speakers is an expert in a different facet of building scalable applications.  They are industry leaders in compute clouds, data grids, object caching, streaming media and more.</p>
<p>One thing we haven&#8217;t touched yet is building a web site that performs well.  The person that replied to the meeting reminder said:</p>
<blockquote><p>save your time:<br />
only put strings in session; and only put one item per-user in the session; unless they are doing some heavy form processing.<br />
use native clustering.<br />
put professional load balancer in from.<br />
max pipe.</p></blockquote>
<p>Thanks.  That is a helpful reply.  It immediately invalidates the hours of insightful discussion we&#8217;ve had at past BostonSUG meetings that have spent less than five minutes total dedicated to the problem to which he so generously offers his solution&lt;/sarcasm&gt;.</p>
<p><img class="alignnone size-medium wp-image-107" title="traditional-web-architecture" src="http://blog.anthonychaves.net/wp-content/uploads/2009/01/traditional-web-architecture-300x225.png" alt="traditional-web-architecture" width="300" height="225" /></p>
<p>This is a picture of what is described in the reply post.  As an industry we have known this works for a long time.  That&#8217;s why we don&#8217;t talk about the architecture depicted by this diagram at BostonSUG.  Sure, we&#8217;ll talk about HOW an app server achieve scalability.  We&#8217;ll talk about the implementation, not just about using JBoss or Mongrel.  We got a good look inside GridGain.  We had a guided tour around Terracotta.  BostonSUG evokes deeper discussion than &#8220;small sessions, load balancer, database cluster, done!&#8221;.  <em>You should do that anyway</em>.</p>
<p>Past meetings aside we have a lot to talk about this year.  Rails 3, Java 7, CloudFront, Hibernate Shards, Google AppEngine, tons of topics that push the industry foward.  If you&#8217;re interested in evolving and not building the same old software then come to BostonSUG.  If you&#8217;re interested in building what we know works (and have known since pre-2000) then it&#8217;s not the meeting for you.</p>
<p>I didn&#8217;t intend for this to turn into a meeting plug but I might as well include the link to the meeting announcement.  <a href="http://www.bostonsug.org/2009/01/05/january-28-2009-meeting-announcement/">Wednesday January 28, 2009 @ 6 p.m.  IBM Innovation Center Waltham, MA 02451</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anthonychaves.net/2009/01/22/industry-ignorance/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Scalability round-table/forum on January 28</title>
		<link>http://blog.anthonychaves.net/2009/01/13/scalability-round-tableforum-on-january-28/</link>
		<comments>http://blog.anthonychaves.net/2009/01/13/scalability-round-tableforum-on-january-28/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 21:03:28 +0000</pubDate>
		<dc:creator>Anthony Chaves</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[spring]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://blog.anthonychaves.net/?p=80</guid>
		<description><![CDATA[The Boston Scalability User Group is hosting a technology round-table meeting on Wednesday January 28th at 6 p.m.  The meeting is at the IBM Innovation Center in Waltham, MA.
This is the first time we&#8217;ve done the round-table style meeting and I&#8217;m excited to see how it goes.  Guests are encouraged to come prepared with questions, [...]]]></description>
			<content:encoded><![CDATA[<p>The Boston Scalability User Group is hosting a technology round-table meeting on Wednesday January 28th at 6 p.m.  The meeting is at the IBM Innovation Center in Waltham, MA.</p>
<p>This is the first time we&#8217;ve done the round-table style meeting and I&#8217;m excited to see how it goes.  Guests are encouraged to come prepared with questions, answers and opinions on application scalability tools, strategies and designs.  Hot topics will include platform and software stack, cloud computing and resources, vendor tools and support and CDNs. Those are my guesses about hot topics doesn&#8217;t mean the meeting is limited to those topics.</p>
<p>Guests, be the regular or first-timers, will drive the direction of the discussion.  We&#8217;ll talk about solving technical problems based on past experience or serve as an advisory panel on where and when to use a particular tool.</p>
<p>Full meeting details are at the <a href="http://www.bostonsug.org">BostonSUG web site</a>.  We ask that you sign up for the meeting at the <a href="http://www.bostonsug.org/meeting-registration/">meeting registration page</a> so we have an idea of how much food to buy.  There will be snacks and bottled water at this meeting.</p>
<p>Hope to see everyone on the 28th at 6 p.m.!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anthonychaves.net/2009/01/13/scalability-round-tableforum-on-january-28/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails and Restful Authentication</title>
		<link>http://blog.anthonychaves.net/2008/07/11/rails-and-restful-authentication/</link>
		<comments>http://blog.anthonychaves.net/2008/07/11/rails-and-restful-authentication/#comments</comments>
		<pubDate>Fri, 11 Jul 2008 16:28:01 +0000</pubDate>
		<dc:creator>Anthony Chaves</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[restful_authentication]]></category>

		<guid isPermaLink="false">http://blog.anthonychaves.net/?p=54</guid>
		<description><![CDATA[It&#8217;s been quite a while since my last Ruby on Rails post so let&#8217;s go over a little &#8220;gotcha&#8221; that you might encounter when using the restful_authentication plugin.
Getting started with restful_authentication is fairly easy.  After installing the plugin it&#8217;s just a matter of running the following generate command:
script/generate authenticated user sessions
This will create a migration [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been quite a while since my last Ruby on Rails post so let&#8217;s go over a little &#8220;gotcha&#8221; that you might encounter when using the <a href="http://agilewebdevelopment.com/plugins/restful_authentication">restful_authentication plugin</a>.</p>
<p>Getting started with restful_authentication is fairly easy.  After installing the plugin it&#8217;s just a matter of running the following generate command:</p>
<pre>script/generate authenticated user sessions</pre>
<p>This will create a migration for a users table, a model and controller for users and a sessions controller.  It will also add some named routes to config/routes.rb.</p>
<p>So far so good, right?  Well, a common mistake when generating the model and controllers is to user the singular form of both user and session.  The command will run successfully and do exactly what you told it to do.  You won&#8217;t become aware of a problem until you try to log in for the first time and see this:</p>
<pre class="xml">
<h1>NameError        in SessionsController#create</h1>
<pre>uninitialized constant SessionsController</pre>
<p><code>RAILS_ROOT: C:/rails/bookmarks</code></p>
<div id="traces"><a onclick="document.getElementById('Framework-Trace').style.display='none';document.getElementById('Full-Trace').style.display='none';document.getElementById('Application-Trace').style.display='block';; return false;" href="http://localhost:3000/session#">Application Trace</a> |             <a onclick="document.getElementById('Application-Trace').style.display='none';document.getElementById('Full-Trace').style.display='none';document.getElementById('Framework-Trace').style.display='block';; return false;" href="http://localhost:3000/session#">Framework Trace</a> |             <a onclick="document.getElementById('Application-Trace').style.display='none';document.getElementById('Framework-Trace').style.display='none';document.getElementById('Full-Trace').style.display='block';; return false;" href="http://localhost:3000/session#">Full Trace</a></p>
<div id="Framework-Trace" style="display: none;">
<pre><code>c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:278:in `load_missing_constant'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in `const_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:479:in `const_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/inflector.rb:283:in `constantize'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/string/inflections.rb:143:in `constantize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/route_set.rb:386:in `recognize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:148:in `handle_request'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:107:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in `synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:35:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/webrick_server.rb:112:in `handle_dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/webrick_server.rb:78:in `service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/webrick_server.rb:62:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/servers/webrick.rb:66
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
script/server:3</code></pre>
</div>
<div id="Full-Trace" style="display: none;">
<pre><code>c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:278:in `load_missing_constant'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:467:in `const_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:479:in `const_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/inflector.rb:283:in `constantize'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/string/inflections.rb:143:in `constantize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/routing/route_set.rb:386:in `recognize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:148:in `handle_request'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:107:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in `synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:104:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:120:in `dispatch_cgi'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.1.0/lib/action_controller/dispatcher.rb:35:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/webrick_server.rb:112:in `handle_dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/webrick_server.rb:78:in `service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
c:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/webrick_server.rb:62:in `dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/servers/webrick.rb:66
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
script/server:3</code></pre>
</div>
</div>
<h2 style="margin-top: 30px;">Request</h2>
<p><strong>Parameters</strong>:</p>
<pre>{"commit"=&gt;"Log in",
"authenticity_token"=&gt;"0c0f07222da8ed58d8c6ebcafb9bf32f0bc84143",
"login"=&gt;"anthony",
"password"=&gt;"mysupersecretpassword"}</pre>
<p>Uh oh! what went wrong?  It looks like Rails is looking for a controller called SessionsController.  But we generated one named SessionController.  Why is this happening?  Take a look in the views/session/new.html.erb file.</p>
<pre>&lt;% form_tag session_path do -%&gt;</pre>
<pre>&lt;p&gt;&lt;label for="login"&gt;Login&lt;/label&gt;&lt;br/&gt;</pre>
<pre>&lt;%= text_field_tag 'login' %&gt;&lt;/p&gt;</pre>
<pre>&lt;p&gt;&lt;label for="password"&gt;Password&lt;/label&gt;&lt;br/&gt;</pre>
<pre>&lt;%= password_field_tag 'password' %&gt;&lt;/p&gt;</pre>
<pre>&lt;!-- Uncomment this if you want this functionality</pre>
<pre>&lt;p&gt;&lt;label for="remember_me"&gt;Remember me:&lt;/label&gt;</pre>
<pre>&lt;%= check_box_tag 'remember_me' %&gt;&lt;/p&gt;</pre>
<pre>--&gt;</pre>
<pre>&lt;p&gt;&lt;%= submit_tag 'Log in' %&gt;&lt;/p&gt;</pre>
<pre>&lt;% end -%&gt;</pre>
<p>The form_tag target is session_path.  session_path is created for us by magic because of its mapping in routes.rb.</p>
<pre>map.resource :session</pre>
<p>When mapping a resource like this Rails looks for the controller with the pluralized name of the resource name by default, which means session_path is getting Session<strong>s</strong>Controller.  We can change the behavior by explicitly setting the controller for the resource.</p>
<pre>map.resource :session, :controller =&gt; :session</pre>
<p>Try to log in again and you will be authenticated!  Of course it may just be easier to remember to use the pluralized name of whatever controller you want to use for managing sessions.</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.anthonychaves.net/2008/07/11/rails-and-restful-authentication/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Boston Scalability User Group</title>
		<link>http://blog.anthonychaves.net/2008/02/04/boston-scalability-user-group/</link>
		<comments>http://blog.anthonychaves.net/2008/02/04/boston-scalability-user-group/#comments</comments>
		<pubDate>Mon, 04 Feb 2008 20:59:16 +0000</pubDate>
		<dc:creator>Anthony Chaves</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Personal]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[career]]></category>
		<category><![CDATA[scalability]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://blog.anthonychaves.net/java/2008/02/04/boston-scalability-user-group</guid>
		<description><![CDATA[I&#8217;ve been digging around lately for a Boston area user group dedicated to architectural scalability and I haven&#8217;t been able to find one.  Other user groups that I regularly attend have meetings centered around scalability once in a while, but I&#8217;m looking for something with a schedule dedicated to the topic.  It&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been digging around lately for a Boston area user group dedicated to architectural scalability and I haven&#8217;t been able to find one.  Other user groups that I regularly attend have meetings centered around scalability once in a while, but I&#8217;m looking for something with a schedule dedicated to the topic.  It&#8217;s a hot topic in the industry right now with a lot happening on different fronts and there should be some ongoing professional discussion dedicated what goes into growing an application.</p>
<p>Here are some of the topics I want to talk about:</p>
<ul>
<li>Data growth and access &#8211; What kind of DBMS topologies allow maximum scalability without breaking the budget?  What if the budget wasn&#8217;t a problem?  How do you migrate your data model from hundreds of users to millions of users?  Should you partition user data across shards or keep it in a central database?  How do you profile data access paterns?  Is your application mostly-read or mostly-write?  When should you use an LDAP directory for data storage?  When should you use MySQL and when should you use Oracle?</li>
<li>Application server scaling &#8211; app server clustering, web server integration, load balancing, application session management, data caching</li>
<li>Web Tier &#8211; load balancing reverse proxies, data caching, working with HTTP, considerations for exposing functionality via REST</li>
<li>Language conisderations and platform choices &#8211; Dynamic languages vs. Static languages, Linux vs. Windows, Solaris vs. Linux, RedHat vs. Oracle, IBM vs. Oracle &#8211; How do you make these choices?  What evaluation critera are most important?  Which ones are misleading?</li>
<li>Framework scalability &#8211; How can you scale if your framework can&#8217;t?  Does Rails really scale better than Spring Web MVC?  Where do PHP frameworks fit in?  What are the alternatives?  This is where we will investigate what you gain and lose by binding yourself to a particular framework, how to keep the coupling to a minimum and how to use your framework as a solid foundation instead viewing it as a cage.</li>
<li>Emerging technology &#8211; Should you become familiar with Map Reduce and Hadoop?  What kind of impact do object databases have on your application?  Should you buy your own Sun or Dell boxes or use Amazon&#8217;s EC2 and S3?</li>
<li>Application architecture &#8211; How do you write an application that scales?  What does your application look like as it grows from servicing hundreds to millions of users?  How does it handle session management?  How does it access datastores?  Are there any design patterns that are helpful?  What are the anti-patterns to be aware of?</li>
</ul>
<p>Like I said, I haven&#8217;t found a group dedicated to discussing these topics.  If you know of one in the Boston area please let me know.  Assuming there isn&#8217;t one <strong>I am willing to start one</strong>.  I&#8217;d like to start off small and meet at coffee shops around Burlington or Lowell.  I have no delusions that this is going to start off or even become as big as NEJUG is now.  If it starts off as a few people getting together to talk about scalability trends, cool caching solutions and specific products then I&#8217;d call it a good start.</p>
<p>The meeting location is still TBD and will be based on how many people are interested in attending.  It will probably be somewhere in Burlington, MA.  There is no planned presentation at this time.  Instead we will have a meet and greet and then discuss scalability trends and news, what approaches to scalability are commonly used now and what are the plans for the future.</p>
<p>If you are interested in coming or in finding out more information please email me at &lt;my first name&gt;@&lt;my domain name&gt;.&lt;my tld&gt; or leave a comment below.  Please make sure to include your email address when you fill out the form so that I can get in touch with you &#8211; your email address will not be displayed on my site.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anthonychaves.net/2008/02/04/boston-scalability-user-group/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Modules, Mixins and name clashes</title>
		<link>http://blog.anthonychaves.net/2006/07/01/ruby-modules-mixins-and-name-clashes/</link>
		<comments>http://blog.anthonychaves.net/2006/07/01/ruby-modules-mixins-and-name-clashes/#comments</comments>
		<pubDate>Sun, 02 Jul 2006 02:56:03 +0000</pubDate>
		<dc:creator>anthony</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.actechnotes.com/blog/?p=8</guid>
		<description><![CDATA[
Ruby allows the creation of modules that provide namespaces for methods and constants to live.  They are also used to mixin these methods and constants into classes.  These mixed-in modules provide a class with references to whatever is defined within the module.  Below is a small (meaningless) Ruby module.


module AnthonyModule
  CONST_DATA [...]]]></description>
			<content:encoded><![CDATA[<p>
Ruby allows the creation of modules that provide namespaces for methods and constants to live.  They are also used to <em>mixin</em> these methods and constants into classes.  These mixed-in modules provide a class with references to whatever is defined within the module.  Below is a small (meaningless) Ruby module.
</p>
<pre>
module AnthonyModule
  CONST_DATA = "I am a constant from AnthonyModule"

  def who_am_i
    puts "My name is: #{@name}"
  end

  def ten_times write_me
    10.times { puts "#{write_me}" }
  end
end
</pre>
<p>
This module provides two methods and one constant.  When this module is mixed in with a class these methods will become instance methods of the class.  Below is an example of using the require method to load the AnthonyModule.rb file and the include method to reference the module in the class.
</p>
<pre>
require "AnthonyModule"

class MyClass
  include AnthonyModule

  def initialize name
    @name = name
  end

end
</pre>
<p>
Notice this class does not have a method called ten_times defined in it.  However when an instance of this class is created it will have a ten_times method because the AnthonyModule is included.  A call to this method is shown below.
</p>
<pre>
m = MyClass.new "Instance 1"
m.ten_times "Hello modules!"
</pre>
<p>
This will produce ten lines each with &#8220;Hello modules!&#8221; printed on it.    Now what happens if another module is introduced that provides another method also named ten_times?
</p>
<pre>
module NewModule
  CONST_DATA = "I am a constant in newmodule.rb"

  def ten_times multiply_me
    puts "ten times #{multiply_me} is: #{ 10 * multiply_me }"
  end
end
</pre>
<p>
Using require and include to mix in NewModule into the class there are now two methods with the same name and signature in the class.  Because Ruby looks in the module included last in a class it will find the NewModule#ten_times method before the AnthonyModule#ten_times method.  Running the sample code gives an error now.
</p>
<pre>
ruby/NewModule.rb:5:in `*&#39;: String can&#39;t be coerced into Fixnum (TypeError)
</pre>
<p>
The problem here is that Ruby does not know how to multiply a number by a string.  I don&#39;t want to do this though, I want to print out my message ten times.  Because I&#39;m calling the ten_times method outside of the class I can&#39;t specify exactly which ten_times method I want to call.  Ruby picks the first one it finds searching backwards (upwards) through the include list.  It appears as though using mixed in methods with a name clash outside of the class can not be done.  If the module&#39;s methods were called in some class methods the module name could be used to differentiate between which method should be called.  Outside the class there is no such luck.
</p>
<p>
I&#39;ll be starting a Rails app later.
</p>
<p>
Anthony</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anthonychaves.net/2006/07/01/ruby-modules-mixins-and-name-clashes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby threads and processes</title>
		<link>http://blog.anthonychaves.net/2006/06/26/ruby-threads-and-processes/</link>
		<comments>http://blog.anthonychaves.net/2006/06/26/ruby-threads-and-processes/#comments</comments>
		<pubDate>Mon, 26 Jun 2006 07:53:17 +0000</pubDate>
		<dc:creator>anthony</dc:creator>
				<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.actechnotes.com/blog/?p=9</guid>
		<description><![CDATA[
I made quite a bit of progress in reading the Pick Axe Book over the weekend.  I wrote a little program to reflect what I read and to scratch an itch of mine too.


I have three processes that I want to run at all times if it can be helped, but it&#39;s ok if [...]]]></description>
			<content:encoded><![CDATA[<p>
I made quite a bit of progress in reading the <a href="http://pragmaticprogrammer.com/titles/ruby/index.html">Pick Axe Book</a> over the weekend.  I wrote a little program to reflect what I read and to scratch an itch of mine too.
</p>
<p>
I have three processes that I want to run at all times if it can be helped, but it&#39;s ok if there is some downtime for each.  Whether these processes are started at system boot time or any time later doesn&#39;t make a difference to me, if they go down I want to start them back up.  For a (very short) time I just blindly used the cron for my user account to start the processes once every X hours.  Unfortunately this meant that five instances of the <a href="http://www.unrealadmin.org/">Unreal Tournament 2004 server</a> would be running at once.  svnserve would fail and send me email every few hours when it was invoked and <a href="http://www.jboss.org">JBoss</a> would consume far too many resources because it was running too many instances.  Using the cron to blindly kick off the servers was a bad idea.
</p>
<p>
Because I wanted to use the cron or an equivalent to periodically check on the servers I had to come up with a way to determine if the servers were already running before trying to start them again.  I came up with two short <a href="http://www.ruby-lang.org">Ruby</a> scripts to solve this problem.  The first is a class to represent the process to monitor and start.
</p>
<pre>
class ProcessMonitor

  def initialize(name, processString, restartCmd)
    @name, @processString, @restartCmd = name, processString, restartCmd
  end

  def get_process_list
    @ps = IO.popen("ps -ef", "r")
  end

  def is_running?
    re = Regexp.new(".*?#{@processString}.*?")
    @ps.each do | line |
      if re.match(line)
        return true
      end
    end
    return false
  end

  def restart_process
    puts "Process  is not running.  Trying to restart."
    process = Process.fork { system("#{@restartCmd}") }
    Process.detach(process)
  end

  def run
    get_process_list
    if !is_running?
      restart_process
    end
  end

end
</pre>
<p>
The constructor takes a name (which doesn&#39;t do anything at this point), a substring of the process to look for in the ps output and the command used to restart the process if it isn&#39;t running.  The get_process_list serves only to get a ps listing of all the processes running.
</p>
<p>
The is_running? method examines each entry in the listing until it finds a process that matches the processString snippet passed in when the object was created.  The run method will execute the restartCmd string only if the process is not running.  The restart_process method uses the Process.fork method to start the command as a process outside the current Ruby interpreter.  It then detaches any interest in that long running process, enabling the Ruby interpreter to exit normally.
</p>
<p>
I should point out that I had some trouble debugging what turned out to <em>not</em> be a problem.  I developed this class in <a href="http://www.eclipse.org">Eclipse</a> using <a href="http://www.radrails.org"></a> and the Ruby interpreter would not terminate when run from inside Eclipse.  Running the program on the command line works without this strange hang.
</p>
<p>Because I do not want to provide a cron entry to call this class for each process I want to monitor I have written a small driver class that takes input from a file.
</p>
<pre>
require "process_monitor"</p>
<p>filename = ARGV[0]</p>
<p>processes = Array.new</p>
<p>IO.foreach(filename) do | line |<br />
  params = Array.new<br />
  line.each("::") do | param |<br />
    params </p>
<p>
This script takes one filename as its argument.  Each line in the file should contain a "::"-delimited list of parameters to create a ProcessMonitor object with.  After parsing each line a new ProcessMonitor object is created and run in a new thread.  After all threads have been run the script waits for each to finish and the program exits.  I plan to put error handling and write test cases sometime this week.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.anthonychaves.net/2006/06/26/ruby-threads-and-processes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
