<?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>Thinking In Rails &#187; Help</title>
	<atom:link href="http://thinkinginrails.com/category/help/feed/" rel="self" type="application/rss+xml" />
	<link>http://thinkinginrails.com</link>
	<description>A Perl Programmer&#039;s Exploration of The World of Ruby on Rails</description>
	<lastBuildDate>Thu, 12 Apr 2012 03:37:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>When and Where to use Caching In Rails</title>
		<link>http://thinkinginrails.com/2010/05/when-and-where-to-use-caching-in-rails/</link>
		<comments>http://thinkinginrails.com/2010/05/when-and-where-to-use-caching-in-rails/#comments</comments>
		<pubDate>Tue, 11 May 2010 21:08:11 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Help]]></category>

		<guid isPermaLink="false">http://thinkinginrails.com/?p=455</guid>
		<description><![CDATA[(Alternative title to this post: Rails Caching Enlightenment Through Perl) This entire post will either make you think I’m a horrible web programmer, or hopefully, show you the deep and meaningful insights that I’ve managed to eke out from the experience. Server Crashes Are Bad Last night I was up coding, but sadly, not rails [...]]]></description>
			<content:encoded><![CDATA[<p>(Alternative title to this post: <em>Rails Caching Enlightenment Through Perl</em>)</p>
<p><a href="http://thinkinginrails.com/wp-content/uploads/2010/05/copypaper.gif"></a>This entire post will either make you think I’m a horrible web programmer, or hopefully, show you the deep and meaningful insights that I’ve managed to eke out from the experience.</p>
<p><strong>Server Crashes Are Bad</strong><br />
<a href="http://thinkinginrails.com/wp-content/uploads/2010/05/6a0112796e0b0a28a40120a725222d970b.gif"><img class="alignright size-full wp-image-463" title="Angry Client" src="http://thinkinginrails.com/wp-content/uploads/2010/05/6a0112796e0b0a28a40120a725222d970b.gif" alt="" width="181" height="231" /></a>Last night I was up coding, but sadly, not rails code. Yesterday I had a call from a client telling me that the website had crashed, and <em>their</em> clients were pissed off because this happened just when they had put out their weekly newsletter. The server (a virtual hosted system hosted at GoDaddy) had locked up tight, rendering all the sites that were on the server un-reachable.</p>
<p>The server was rebooted, and digging into it there was no clear reason why it had crashed, which is of course not what they wanted to hear. I had a development server set up at home, so I did a bit of testing to see if I could duplicate it. The server was old and slow (not even dual core), but usable as a Linux workstation, so I figured that if I could make the site feel faster here, the gains on the production server would be huge.</p>
<p><strong>Determining A Baseline</strong><br />
First was to hit it with the trusted <a href="http://httpd.apache.org/docs/2.0/programs/ab.html">Apache Benchmark</a> utility, I started with a perfectly reasonable 10 concurrent connections for 1000 hits hitting the landing page that was sent out in the newsletter, and probably one of the more intensive pages DB and logic wise on the site.</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">$ ab -c 10 -n 1000 “http://site.com/page.html?id=117”</pre></div></div>

<p>Looking at my system monitor, I immediately saw my CPU use jump to 100%, disk access go from a blip here and there to constant, and the machine ground to a halt.</p>
<p>I hit ctrl-c pretty fast.</p>
<p>OK, problem found, the site is a vampire and sucks the life out of the server. I played with a few different settings and eventually ended up using 5 concurrent connections and 20 hits “-c 5 -n 20” which gave me an average 2000-4000ms to serve pages, about 1 request a second.</p>
<p>Horrible right? Before you put me against the wall to keep me from doing <em>any</em> web programming again, remember this is a really old server. Please? Maybe one smoke before it’s time for me to go?</p>
<p><strong>Small Fixes, Small Gains</strong><br />
So there were three things that I figured I needed to look at:</p>
<ol>
<li> Use the <a href="http://developer.yahoo.com/yslow/">YSlow </a><a href="http://developer.yahoo.com/yslow/">plugin</a> to find some small gains</li>
<li> Finally see if there are any just bad code that could be refactored out, loops within loops, useless re-calculation, etc.</li>
<li> Re-examine the number of queries going on on the page</li>
</ol>
<p>YSlow gave me a <a href="http://developer.yahoo.com/performance/rules.html">few things to do</a>. Setting the expires header for images, moving CSS and JS to the top and bottom of the page, and a couple of other minor things that gave me no real gains via ab.</p>
<p>Surprisingly, there weren’t any low hanging fruit for bad code or useless loops within loops. This sucked, mostly because that meant me going through and re-looking at SQL and refactoring that, which I’m not sure about you, but that doesn’t sound like fun to me.<br />
Somewhat more surprisingly there were only a couple of extra queries, mostly related to the ORM I was using, <a href="http://search.cpan.org/dist/Class-DBI/">Class::DBI</a> and some just silly things. Sadly none of these gave me any more gains.</p>
<p>One thing I did find was where the issues were. When I commented out the main grid of items that is the focus on the page, the page response went from 2000-4000ms response time to 200. Hmm&#8230;, so what to do with this.  What if I could make it so the time to generate the main product grid didn&#8217;t happen?  So I commented out the dynamic code, and copied in the HTML produced (from the view source window in firefox) to see if it was the dynamic generation (which wasn&#8217;t <em>really</em> that complex from what I could see).  Again, 200-400ms time, serving 9-10 requests a second, with almost no CPU or disk impact.</p>
<p>OK, so I thought what if there was a way to pre-generate the HTML periodically, and then have the perl code load that instead of doing it dynamically each time.  That almost sounds like&#8230;.. &#8220;<strong>caching</strong>&#8220;.  Huh, almost like something that should be built in.</p>
<p><strong>Enter Caching</strong><br />
<a href="http://thinkinginrails.com/wp-content/uploads/2010/05/copypaper.gif"><img class="alignright" title="Copy Paper" src="http://thinkinginrails.com/wp-content/uploads/2010/05/copypaper-300x202.gif" alt="" width="300" height="202" /></a>Honestly my experiences with caching have been minimal, most of the time I am trying to <strong>prevent</strong> caching (for re-uploaded images with the same filename, that sort of thing), and also it just hadn&#8217;t come up yet, probably because most of the sites I have worked on don&#8217;t get huge enough traffic to require it.  Luckily I had just read something about Caching in the <a href="http://www.masonhq.com/docs/manual/Devel.html">HTML::Mason developer docs</a> while finding some information for something else.</p>
<p>HTML::Mason has the concept of &#8220;components&#8221;, similar to partials in the rails world.  You&#8217;d call something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;">blah blah
<span style="color: #339933;">&lt;</span> <span style="color: #339933;">&amp;</span> <span style="color: #ff0000;">&quot;/comp/gallery.mc&quot;</span><span style="color: #339933;">,</span> id <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$id</span><span style="color: #339933;">,</span> page <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$cur_page</span><span style="color: #339933;">,</span> title <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">&quot;TiR&quot;</span> <span style="color: #339933;">&amp;&gt;</span>
blah blah</pre></div></div>

<p>When the page is rendered it would call the gallery.mc component with the given arguments, render it, running whatever code is in there (<a href="http://www.masonhq.com/">HTML::Mason</a> isn&#8217;t the nice separated MVC that Rails is, so there&#8217;s potentially lots of controller code in your pages and components) and replacing the &lt; &amp; &amp;&gt; with the output.  The documents have a nice section on the built in page and component (think fragment) <a href="http://www.masonhq.com/docs/manual/Devel.html#data_caching">caching</a> where all you need to do is to add this code to the top of your component&#8217;s &#8220;init&#8221; section:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #000066;">return</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$m</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">cache_self</span><span style="color: #009900;">&#40;</span>key <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'fookey'</span><span style="color: #339933;">,</span> expires_in <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'3 hours'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>other options<span style="color: #339933;">...</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This lets your component see if it&#8217;s already in the cache, and not expired, and if it is, serves that, and if not, renders and then caches itself with the given key.  The only tricky part is figuring out the right cache key to ensure it&#8217;s unique for each section of code.  I ended up writing something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #0000ff;">$key</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;gallery|$id|$cur_page|$title&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000066;">return</span> <span style="color: #b1b100;">if</span> <span style="color: #0000ff;">$m</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">cache_self</span><span style="color: #009900;">&#40;</span>key <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">$key</span><span style="color: #339933;">,</span> expires_in <span style="color: #339933;">=&gt;</span> <span style="color: #ff0000;">'10 minutes'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#91;</span>other options<span style="color: #339933;">...</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>This makes the cache key a hash of the arguments sent to the component, ensuring that each differently rendered version of the page will get a different cache key. Not perfect I&#8217;m sure, but a nice mix of good caching and safety.</p>
<p>Running &#8216;ab&#8217; again I found that while the first couple of requests still took 2000-4000ms to run, subsequent pages were served in the 200-400ms range, and the CPU and disk load was <em>way</em> down.</p>
<p><strong>WTF &#8211; This is a Rails Blog</strong><br />
So why am I telling you all this Perl stuff? It’s because this is related more to web programming and programmer mindset than Perl or HTML::Mason.  You could replace &#8220;perl&#8221; with &#8220;ruby&#8221;, &#8220;component&#8221; with &#8220;partial&#8221; and &#8220;HTML::Mason&#8221; with &#8220;Rails&#8221; and get the same idea.</p>
<p>Because everything ran fine when the site was under development and only two or three people were hitting it I didn&#8217;t have to worry about caching or performance issues.  In fact, I didn&#8217;t even <strong>think</strong> about performance because thigns &#8220;just worked&#8221;.  When things did go badly (again, server crashes == pissed off clients), I had to scramble to find a solution (luckily only one night of work).</p>
<p>I&#8217;m still doing testing with the new caching code, but I expect to put it online tonight or tomorrow, and look forward to the before and after numbers on the production server.</p>
<p><strong>Lessons Learned</strong><br />
My lessons learned:</p>
<ul>
<li> Watch <strong>from the start</strong> for cachable pieces of code.  Big complex SQL queries or complex logic that can be created once a week, day or even every minute is a candidate.  In Rails it can be as simple as surrounding the code with &lt; % cache do %&gt; .. &lt; % end %&gt;.</li>
<li> Test performance from the onset.  Learn to love <a href="http://httpd.apache.org/docs/2.0/programs/ab.html">Apache Benchmark</a> and start hitting your sites potential hot pages from the start, and watch and learn what causes reponsiveness to go down.</li>
</ul>
<p><strong>Resources</strong><br />
For those of you wanting some actual <em>rails</em> resources to learn more about this stuff, have a look at the following:</p>
<ul>
<li> <a href="http://www.cyberciti.biz/tips/howto-performance-benchmarks-a-web-server.html">Understanding &#8216;ab&#8217; results</a> &#8211; Nice resource for how to read that output.</li>
<li> <a href="http://guides.rails.info/caching_with_rails.html">Caching with Rails</a> &#8211; The rails guides documentation with details on page, fragment, action caching and everything in between.</li>
<li> <a href="http://thewebfellas.com/blog/2008/6/9/rails-2-1-now-with-better-integrated-caching">Rails 2.1 Caching</a> &#8211; A bit older, but a nice list of the caching capabilities introduced and available in Rails 2.1, still pretty relevant.</li>
<li> <a href="http://railslab.newrelic.com/scaling-rails">The Scaling Rails Podcast Series</a> &#8211; Fantastic information in here, I recommend watching all of them, if you can&#8217;t, hit #2, 3, 5, 6, 7 for caching, and then #15 and 16 for load testing with ab and friends.</li>
</ul>
<div>Any other resources or hints as to how to deal with caching in Rails (or Perl for that matter! <img src='http://thinkinginrails.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ?</div>
]]></content:encoded>
			<wfw:commentRss>http://thinkinginrails.com/2010/05/when-and-where-to-use-caching-in-rails/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Anatomy of A Ruby Gem</title>
		<link>http://thinkinginrails.com/2010/05/anatomy-of-a-ruby-gem/</link>
		<comments>http://thinkinginrails.com/2010/05/anatomy-of-a-ruby-gem/#comments</comments>
		<pubDate>Fri, 07 May 2010 03:01:22 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Help]]></category>
		<category><![CDATA[Instructions]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://thinkinginrails.com/?p=431</guid>
		<description><![CDATA[If you&#8217;ve ever installed a Ruby gem off of gemcutter or github, you&#8217;ll know that you run the gem install &#60;gemname&#62; command and when it&#8217;s completed you magically have access to use it through &#8216;require &#60;gemname&#62;&#8217;.  If you&#8217;ve ever looked into the source you might want to have an idea of what goes where and [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever installed a Ruby gem off of gemcutter or github, you&#8217;ll know that you run the gem install &lt;gemname&gt; command and when it&#8217;s completed you magically have access to use it through &#8216;require &lt;gemname&gt;&#8217;.  If you&#8217;ve ever looked into the source you might want to have an idea of what goes where and how it all works.</p>
<p>First of all, I&#8217;m fairly new to this myself, so it&#8217;s very possible that I&#8217;ll miss something vital, please feel free to flame me in the comments, as long as you tell me where I messed up so I can fix it <img src='http://thinkinginrails.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><span id="more-431"></span></p>
<p>Lets take a couple of examples.  One is a gem for dissecting XML feeds that I just discovered, <a href="http://github.com/pauldix/feedzirra">feedzirra</a>, the other is a bit more complex, <a href="http://github.com/injekt/cinch">Cinch</a>, the IRC micro-framework I was talking about a few days ago.  Starting with feedzirra, here&#8217;s the listing of the files and directories in the root of the gem, I&#8217;ll take them one by one.</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">README.rdoc
README.textile
Rakefile
feedzirra.gemspec
lib/
spec/</pre></div></div>

<p><strong>README.*</strong></p>
<p>The first two are pretty obvious, they are the README files with GitHub (and others) automatically parses out and displays when you hit the main project page.  Here is a <a href="http://github.com/guides/readme-formatting">list of the README formats that github supports</a>, as well the order that it will display them in.  Here the author has included a README file as well as a README.textile (<a href="http://textile.thresholdstate.com/">texttile</a> is a simple markup language), and github displays the REAMDE.[something] first.</p>
<p><strong>Rakefile</strong></p>
<p><a href="http://rake.rubyforge.org/">Rake</a>, as you know is the ruby version of &#8220;make&#8221; the venerable Unix utility.  Inside the Rakefile you find a <a href="http://rake.rubyforge.org/files/doc/rakefile_rdoc.html">formatted</a> set of rules in the form of tasks and targets.  Hit <a href="http://onestepback.org/index.cgi/Tech/Rake/Tutorial/RakeTutorialRules.red">this tutorial</a> for some more details.  The short story is that there are targets (with prerequisite/dependency information) such as install, uninstall, and release, supporting functions if needed, and some boilerplate info (description, name, contact, etc).  The targets can be anything it seems, for example Feedzirra has a task for releasing and uploading a new release, whereas cinch just has an &#8216;install&#8217; task.  Rake is used a lot to help the creation of gems, but I don&#8217;t think that it&#8217;s used in the actual installation.</p>
<p><strong>[gemname].gemspec</strong></p>
<p>Here is the meat of it all, the gemspec file consists of the control information for the entire gem.  If you check out <a href="http://asciicasts.com/episodes/183-gemcutter-jeweler">this tutorial</a> you&#8217;ll see that it&#8217;s ruby code and can be created with a few utility scripts including Rake, and has some of the following information:</p>
<ul>
<li>Gem name and information (homepage, description)</li>
<li>Author information (email, etc)</li>
<li>Version and Date</li>
<li>Other gem dependencies</li>
<li>One or more boolean flags (ie: is there documentation that needs to be generated)</li>
<li>A file list of what files need to be installed</li>
<li>A list of executables of files that will be put in the bin directory when they&#8217;re installed</li>
</ul>
<p><strong>lib/ And Other Files or Directories</strong></p>
<p>Basically what&#8217;s left are directories of files that are going to be installed on your system.  Of course, &#8220;lib&#8221; isn&#8217;t always going to be there, but for most gems that are adding a new class into your ruby environment, it will be.  The gemspec file has the list of the files and directories that will actually be taken out of the gem and installed into your system.  There are different ways to specify these files in gemspec, as you&#8217;ll see by comparing the <strong>s.files</strong> directive in the <a href="http://github.com/injekt/cinch/blob/master/cinch.gemspec">Cinch gemspec</a> and the <a href="http://github.com/pauldix/feedzirra/blob/master/feedzirra.gemspec">Feedzirra gemspec</a>.</p>
<p>Inside the lib/ directory there will generally be one or two main files.  In Cinch you have:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">cinch/
cinch.rb</pre></div></div>

<p>This is the module that is loaded when you do a &#8216;require &#8220;cinch&#8221;&#8216; and the cinch/ directory has the supporting files.  The cinch.rb module file has a bunch of requires of &#8220;cinch/irc&#8221;, &#8220;cinch/rbase&#8221;, etc which are the sub-modules that it uses.  More on Modules vs Classes in a later post.</p>
<p><strong>spec/</strong></p>
<p>This will be the specs that the author has put in his source tree and includes so that other developers can look and use their tests.  Again, this isn&#8217;t going to <em>always</em> be there, but it seems to be very in vogue to do this whole &#8220;testing&#8221; thing, and including your spec or test directory is The Right Thing To Do.</p>
<p><strong>File Locations</strong></p>
<p>So when you run &#8216;gem install [foo]&#8216; where do the files go?  Lets use Cinch again for this one as it&#8217;s fairly simple.  Here&#8217;s a listing of the files that are in the source on github:</p>

<div class="wp_syntax"><div class="code"><pre class="shell" style="font-family:monospace;">./LICENSE
./lib/cinch.rb
./lib/cinch/irc
./lib/cinch/irc/parser.rb
./lib/cinch/* [ more library module files ]
./examples/hello.rb
./examples/* [ more example files ]
./README.rdoc
./spec/irc/parser_spec.rb
./spec/* [ more specs ]
./Rakefile
./cinch.gemspec</pre></div></div>

<p>(Note some of the directories are abbreviated).</p>
<p>When you do a <strong>gem install</strong> the files moved into the path defined in $GEM_HOME thusly:</p>
<pre>cinch/lib           =&gt; $GEM_HOME/gems/cinch-0.2.6/lib
cinch/examples      =&gt; $GEM_HOME/gems/cinch-0.2.6/examples
[...]
cinch/README.rdoc   =&gt; $GEM_HOME/gems/cinch-0.2.6/README.rdoc
                    =&gt; $GEM_HOME/doc/cinch-0.2.6/ri/*
                    =&gt; $GEM_HOME/doc/cinch-0.2.6/rdoc/*
</pre>
<p>Nothing <em>hugely</em> interesting, files are basically just moved into your gem home directory under a directory named with the name and version of the gem you&#8217;re installing.  Note that the doc/*/ri and doc/*/rdoc files are auto-created when the gem install runs, if you don&#8217;t pass the &#8211;no-ri or &#8211;no-rdoc flags of course.  The internal magic in rubygems and ruby allow your programs to find the gems when they are &#8216;required&#8217;.</p>
<p><strong>How to Examine A Gem</strong></p>
<p>One of the nicest ways to play with these things, and what I did was  to use <a href="http://rvm.beginrescueend.com">RVM</a> and then doing a gem  install, as well as using git clone to pull down the source files from  github.  RVM, combined with it&#8217;s great <a href="http://rvm.beginrescueend.com/gemsets/">gemset support</a>, is  a great tool and makes it really easy to add, remove, and play with no  fear of mucking things up.</p>
<p><strong>Conclusion</strong></p>
<p>So that&#8217;s about it for the normal library gems that you&#8217;ll find on github.  Hopefully you now understand a bit more about how a gem is structured and what happens when you install and use gems, and how they will interact with each other.  I found lots of resources out there, including some great stuff on how to create your own gems, gemspec files, and so on, listed below.</p>
<p><strong>Additional Reading</strong></p>
<ul>
<li><a href="http://docs.rubygems.org/read/chapter/5">http://docs.rubygems.org/read/chapter/5</a></li>
<li><a href="http://rubygems.org/pages/gem_docs">http://rubygems.org/pages/gem_docs</a></li>
<li><a href="http://railscasts.com/episodes/135-making-a-gem">http://railscasts.com/episodes/135-making-a-gem</a></li>
<li><a href="http://asciicasts.com/episodes/183-gemcutter-jeweler">http://asciicasts.com/episodes/183-gemcutter-jeweler</a></li>
<li><a href="http://buzaz.com/index.php/2010/01/03/how-to-build-a-ruby-gem/">http://buzaz.com/index.php/2010/01/03/how-to-build-a-ruby-gem/</a></li>
<li><a href="http://docs.rubygems.org/read/chapter/20">http://docs.rubygems.org/read/chapter/20</a></li>
<li><a href="http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended/">http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://thinkinginrails.com/2010/05/anatomy-of-a-ruby-gem/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails Lingo For Beginners</title>
		<link>http://thinkinginrails.com/2010/04/ruby-on-rails-lingo-for-beginners/</link>
		<comments>http://thinkinginrails.com/2010/04/ruby-on-rails-lingo-for-beginners/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 04:44:54 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Help]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://thinkinginrails.com/?p=326</guid>
		<description><![CDATA[One of the more challenging things starting out in a new language is having to not only learn the new language/framework, but dealing with the jargon that goes along with it.  There&#8217;s nothing more frustrating than finding someone willing to answer your questions, but you can&#8217;t understand what they&#8217;re saying!  Here&#8217;s a few of the [...]]]></description>
			<content:encoded><![CDATA[<p>One of the more challenging things starting out in a new language is having to not only learn the new language/framework, but dealing with the jargon that goes along with it.  There&#8217;s nothing more frustrating than finding someone willing to answer your questions, but you can&#8217;t understand what they&#8217;re saying!  Here&#8217;s a few of the acronyms and terms that you might come across if you&#8217;re a Ruby on Rails newbie, with a perl refugee slant.<img class="alignright" title="Jargon for Ruby on Rails Programmers" src="/images/jargon.jpg" alt="" width="285" height="388" /></p>
<ul>
<li><strong>Gem</strong> &#8211; The basic distribution of most of the plugins and addon libraries for Ruby.  Thing <a href="http://cpan.org">CPAN</a>.  A lot of times you can either install a gem onto your system or as a plugin to a rails project.  The basics are you can run &#8220;gem list&#8221;, &#8220;gem install &lt;gem&gt;&#8221; and &#8220;gem search &#8211;remote &lt;search&gt;&#8221; to list installed gems, install a new gem by name, or search the configured remote gem servers.  Speaking of CPAN, the main two places for gems (currently anyway) are <a href="http://github.com">github</a> and <a href="http://rubygems.org/">rubygems</a>.  The main rubygems distribution is essential to get most of the gem functionality, so you&#8217;ll need to make sure you have the rubygems package (for your OS) installed and working before you can start doing &#8220;gem install&#8221; all crazy like.  More information can be found on <a href="http://docs.rubygems.org/">the rubygems site</a>.</li>
<li><strong>TDD</strong> &#8211; <a href="http://en.wikipedia.org/wiki/Test-driven_development"><strong>T</strong>est <strong>D</strong>riven<strong> D</strong>evelopment</a>.  Ruby and Rails people <em>love</em> testing.  They love it like mom&#8217;s homemade pasta and meatballs served to you with lots of Parmesan cheese after a long day.<em></em> The TDD philosophy basically means that before you write code, you write a test.  In the simplest &#8220;hello world&#8221; case you would write a test to say &#8220;does the program print out &#8216;hello world&#8217;&#8221;.  It of course fails because there is no program written yet.  Then you write the code and work on it until it prints out &#8220;hello world&#8221; and the test passes.  Some people follow TDD to extremes, some ignore it completely (but shouldn&#8217;t) and others work in the grey area in between extremes.</li>
<li><strong>Waterfall</strong> &#8211; The <a href="http://en.wikipedia.org/wiki/Waterfall_model">waterfall model</a> is another design philosophy, but this is more of the old school, not web 2.0, evil-used-by-suits philosophy.  It&#8217;s your classic &#8220;wait till Bob gets the requirements done, then we need the architect team to design the models and system, then we&#8217;ll get you to implement it, it&#8217;ll head into QA for them to test, and eventually it&#8217;ll go into maintenance mode&#8221;.  <em>Yawn</em>.  That&#8217;s not to say that there aren&#8217;t good reasons to use this model, but it&#8217;s considered an old school way of doing things.  You&#8217;ll know what your mentor means and not think he&#8217;s talking about a trip to look at waterfalls anyway.</li>
<li><strong>DHH</strong> &#8211; This of course is the creator of Rails, David Heinemeir Hansson.  You might also hear names like Obie Fernandez, Wayne Seguin, and JEG2 (James Edward Gray II), and these too are people high up in the community.  There are a lot of them, and it&#8217;s a big community, so don&#8217;t feel too bad if you don&#8217;t recognize a name or two.</li>
<li><strong>MVC</strong> &#8211; The <a href="http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller">Model, View, Controller</a> model is at the core of Rails, and if you somehow managed to miss this in the first chapter of <em>any</em> Rails book, I&#8217;m shocked!  However, if you somehow did, you may hear it thrown around and get confused, especially if you come from another programming language and are still used to the old world &#8220;SQL and code inside your HTML file&#8221; world that you&#8217;ll be <em>so</em> happy to escape.</li>
<li><strong>DRY</strong> &#8211; Another big one I&#8217;d be shocked if you didn&#8217;t know, it&#8217;s <a href="http://en.wikipedia.org/wiki/Don%27t_repeat_yourself">Don&#8217;t Repeat Yourself</a>, another tenant of the Ruby and Rails world.  Basically this means that copy and paste programming is not a desired thing, and if you find yourself doing the same bit of code more than once (ie: formatting a price with a $ and decimal places) it&#8217;s best to find a way to move that into it&#8217;s own function so it&#8217;s only in one place.  This makes code easier to maintain, and keeps you happy.  Not a Rails specific philosophy, but definitely a core value.  Next time someone looks at your work and tells you it&#8217;s not DRY you&#8217;ll know what they mean.</li>
<li><strong>Refactoring</strong> &#8211; Closely related to DRY, refactoring is the act of going back and seeing where you can extract common functionality or make the code more idiomatic or simple.  Different from <a href="http://www.c2.com/cgi/wiki?PerlGolf">Golf challenges in Perl</a> by far.  Check out <a href="http://refactormycode.com/">Refactor My Code</a> if you want to get some great examples of how different people take the approach.  This site is <em>awesome</em> as you don&#8217;t just see the end result of good coding (as you&#8217;d see by reading (some) other people&#8217;s source code), but both the start and several alternative results.</li>
<li><strong>Convention over Configuration</strong> &#8211; <a href="http://en.wikipedia.org/wiki/Convention_over_configuration">The idea</a> that by following naming and file conventions, and following them, productivity goes up over a framework that allows you to configure where files are, how classes are named, etc.  By having a set of standard practices that you know your system follows, you can concentrate on what you&#8217;re doing and get sh$t done!  This is probably the <em>most</em> important tenant of Rails, and is pretty much what the entire thing is built on.</li>
<li><strong>Framework</strong> &#8211; Going back a bit, what the heck <em>is</em> a <a href="http://en.wikipedia.org/wiki/Web_application_framework">framework</a>.  Short answer is it&#8217;s something you build your applications in which provides you with everything you need.  In other words, instead of you having to deal with HTTP POST parameters for string processing, it provides you with libraries for data handling and common functionality.</li>
<li><strong>CRUD</strong> &#8211; Speaking of things you don&#8217;t have to deal with, the biggest thing that I think web app developers have to deal with is the four common actions you&#8217;re taking with data (think editing a list of blog posts): <a href="http://en.wikipedia.org/wiki/Create,_read,_update_and_delete"><strong>C</strong>reate, <strong>R</strong>etrieve, <strong>U</strong>pdate, and <strong>D</strong>elete</a>.  This is shorthand for telling people that the data you&#8217;re dealing with has (or needs) the standard set of actions to edit, delete, show and create functionality.  This goes hand in hand with our last one&#8230;</li>
<li><strong>Scaffolding</strong> &#8211; This is the concept of creating a default set of functionality that the programmer can update later on.  This is a quick and dirty way of getting things working, and is, in most cases, either only used for learning purposes or is rewritten later.  Creating a scaffold for a set of data (say a blog post) can be done in rails by running &#8220;script/generate scaffold Post title:string body:text&#8221;.  This will create a <a href="http://en.wikipedia.org/wiki/Scaffold_%28programming%29">scaffolding</a> which lets you have access to the CRUD operations on this new data model.  With just that one line above you get all the HTML, form processing, and database layer interaction needed to fully perform CRUD operations.  The concept of using scaffolding to create quick and easy access to data is a huge part of Rails&#8217; success (even if you <em>do</em> end up rewriting them eventually, or grow out of using scaffolding as your skills improve).</li>
</ul>
<p>There are <em>lots</em> more out there (<a href="http://www.brianburridge.com/2007/08/09/rails-terms-and-concepts/">this page</a> has a great list).  Phusion, Heroku, nginx, nokogiri, sass, haml, copilot and scout are other terms for some specific software and sites and libraries you might come across.</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkinginrails.com/2010/04/ruby-on-rails-lingo-for-beginners/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Favorite Ruby and Rails Podcasts</title>
		<link>http://thinkinginrails.com/2010/04/favorite-ruby-and-rails-podcasts/</link>
		<comments>http://thinkinginrails.com/2010/04/favorite-ruby-and-rails-podcasts/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 04:23:42 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Help]]></category>
		<category><![CDATA[Resources]]></category>

		<guid isPermaLink="false">http://thinkinginrails.com/?p=309</guid>
		<description><![CDATA[Podcasts have been a great help to get some great information about Ruby and Rails, as well as to discover and connect with more of the community.  I figured I'd list a few that I listen to, and would appreciate folks passing back any good ones I might be missing.]]></description>
			<content:encoded><![CDATA[<p>Podcasts have been a great help to get some great information about Ruby and Rails, as well as to discover and connect with more of the community.  I figured I&#8217;d list a few that I listen to, and would appreciate folks passing back any good ones I might be missing.</p>
<p>Some will be old hat to the ruby folks, but there might be some new ones that could <span style="text-decoration: line-through;">peak</span> pique your interest.  If you&#8217;re a newbie to Rails like me, I suggest you add these to your podcast watcher of choice immediately!  Most of these will fall into either the &#8220;news of the week&#8221;, &#8220;interviews&#8221;, &#8220;howto&#8221; or &#8220;training&#8221; categories.  I&#8217;ll categorize them for you a bit so you can pick and choose if you prefer one or the other.  There are a few that I&#8217;ve picked out that aren&#8217;t strictly Rails or Ruby oriented, but they still get prime location in my weekly podcast listening.</p>
<ul>
<li><strong><a href="http://coderpath.com/">Coderpath</a></strong> [<a href="http://itunes.apple.com/podcast/coderpath-podcast/id214162182">itunes</a>] (audio,interviews) <a href="http://twitter.com/milesforrest">@milesforrest</a> and <a href="http://twitter.com/curtismchale">@curtismchale</a><br />
Ok, so even though this is a bit of shameless not-quite-my-own self promotion, and Miles and Curtis are buddies of mine, I do have to honestly recommend the Coderpath podcast.  They do interviews of some of the big names in the Rails community such as DHH, Ryan Bates, Wayne Seguin and others, and ask a lot of good questions about some of the &#8220;how&#8221; of the community, the sort of questions someone like me might ask (and I do).  Also keep an eye on Miles&#8217; twitter feed as he&#8217;ll send out where you can submit questions for the podcast.</li>
<li><strong><a href="http://railscasts.com">RailsCasts</a></strong> [<a href="http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=218282043">itunes</a>] (video, training) <a href="http://twitter.com/rbates">@rbates</a><br />
Ryan Bates&#8217; great podcast is a staple of the Rails community, and he gives short, bite sized chunks of information on different aspects of rails programming.  One week it might be how to do something like nested routes, another will be a series of Rails 3 howtos.  Awesome stuff.  Personally I&#8217;d recommend watching these and not deleting them, so you can go back for further reference later on.</li>
<li><strike><strong><a href="http://charlesmaxwood.com/">Rails Coach</a></strong></strike> <strong><a href="http://teachmetocode.com/podcast/">Teach Me To Code Podcast</a></strong> [<a href="http://itunes.apple.com/ca/podcast/teach-me-to-code-podcast/id346089573">itunes</a>] (audio, interviews, training and howto) <a href="http://twitter.com/charlesmaxwood">@charlesmaxwood</a> <strong>Note: </strong>Updated link, RailsCoach is now Teach Me To Code Podcast<br />
This is a recent discovery of mine, and Charles does a great job in intermixing interviews and talking about how to do various issues, such as finding a mentor or how to take the best advantage of your first (Rails|Ruby)Conf.  My favourite part of this podcast is that he seems to be (and no insult intended) about on my level, or a bit above, so a lot of the questions he asks would be pretty much exactly what I&#8217;d want to know in the same situation.</li>
<li><strong><a href="http://vimcasts.org/">VimCasts</a></strong> [<a href="http://itunes.apple.com/ca/podcast/vimcasts/id350035635">itunes</a>] (video, training) <a href="http://twitter.com/nelstrom">@nelstrom</a><br />
Not purely a Ruby or Rails podcast, but vim is a skill that every programmer should know, and Drew does a great job in giving both a newbie friendly, and old-hat educating, series of screencasts.  If it says anything to you, I&#8217;ve been using vi and vim since around 1995 and was still learning things from the first podcast.  Great stuff in easy to digest chunks like <a href="http://railscasts.com">RailsCasts</a>.</li>
<li><strong><a href="http://railslab.newrelic.com/scaling-rails">RailsLab Scaling Rails</a></strong> [<a href="http://itunes.apple.com/ca/podcast/railslab-scaling-rails/id303252563">itunes</a>] (video, training) <a href="http://twitter.com/greggpollack">@greggpollack</a><br />
This is a 21 part series that isn&#8217;t being updated anymore, but is a must-watch for anyone who wants to know a bit more about Scaling Rails.  This isn&#8217;t going to be applicable to 90% of what 90% of the audience does, but is still invaluable information in giving you the background information to know why certain decisions you make in technology can have big (or small) impacts on scaling down the road.</li>
<li><strong><a href="http://yourworkflow.ca/">Your Workflow</a></strong> [<a href="http://itunes.apple.com/ca/podcast/id368881313">itunes</a>] (audio, interviews) <a href="http://twitter.com/curtismchale">@curtismchale</a><br />
Ok this is another bit of not-quite-my-own self promotion, as Curtis is a buddy of mine from the <a href="http://fvrb.org/">Fraser Valley Ruby Brigade</a> (FV.rb).  This podcast addresses a niche that isn&#8217;t really addressed in other places, and takes that tack of &#8220;how do you get your job done&#8221; and talks about the workflow that people have.  Curtis is a <a href="http://www.curtismchale.ca">designer</a> and so far his interview has focused on wordpress development, but the site and podcast is all about people&#8217;s workflow, and you&#8217;re sure to find something new.</li>
<li><strong><a href="http://www.rubypulse.com/">Ruby Pulse</a></strong> [<a href="http://itunes.apple.com/ca/podcast/rubypulse/id329025086">itunes</a>] (video, training) <a href="http://github.com/aaalex">aaalex</a><br />
Ruby Pulse is to Ruby what RailsCasts is to Rails.  Alex takes a small chunk of code, a gem, or technology concept and works with it in a 5-10 minute podcast.  Ruby Pulse is unique is that it&#8217;s done in one go, with no editing, so as the intro says, sometimes unexpected things will happen.  More often than not, you&#8217;ll get a nice introduction to a new and interesting gem or two.</li>
<li><strong><a href="http://ruby5.envylabs.com/">Ruby 5</a></strong> [<a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=327234205">itunes</a>] (audio, news) <a href="http://envylabs.com/">Envy Labs</a><br />
Ruby5 is the bite size chunk news show, and gives you the Ruby and Rails news of the week in a five minute podcast a couple of times a week.  Ruby5 was split off of Rails Envy for people who wanted their news a bit more compressed and less &#8220;chatty&#8221;.  Great way to hear what&#8217;s new and interesting and keep yourself right on the edge.</li>
<li><strong><a href="http://5by5.tv/rubyshow">The Ruby Show</a></strong> [<a href="http://itunes.apple.com/ca/podcast/the-ruby-show/id265693109">i</a>], <a href="http://5by5.tv/devshow">The Dev Show</a> [<a href="http://itunes.apple.com/ca/podcast/the-dev-show/id352611845">i</a>] and other good stuff from <a href="http://5by5.tv/shows">5by5</a> (audio, news, interviews)<br />
Those familiar with Rails Envy will recognize these as cut from that tree.  5by5 has a very good series of podcasts with various names in the Rails and open source community, and has a great mix of news and interview shows.  The Ruby Show and the Dev Show are the ones that are on my podcast weekly, but I&#8217;ve also recently discovered <a href="http://5by5.tv/pipeline">The Pipeline</a>, which is an interview show with innovators and newsmakers, and it deserves a listen as well.</li>
<li><strong><a href="http://blog.stackoverflow.com/category/podcasts/">Stack Overflow Podcast</a></strong> [<a href="http://itunes.apple.com/ca/podcast/stackoverflow/id345346712">itunes</a>] (audio, news, howto and interviews) <a href="http://twitter.com/spolsky">@spolsky</a> and <a href="http://twitter.com/jeffatwood">@jeffatwood</a><br />
Another not-really Rails oriented, but Joel Spolsky is a name that should be familiar to anyone doing development, as will StackOverflow.com.  You&#8217;ll also recognize Jeff Atwood from his great <a href="http://codinghorror.com">codinghorror.com</a> site.  The guys get into some of the programming practices they follow, business, and interviewing people in their circle.  It&#8217;s a really interesting look into the development and business of the <a href="http://stackoverflow.com">StackOverflow</a> community.  Just ignore the whole &#8220;.NET&#8221; thing <img src='http://thinkinginrails.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li><strong><a href="http://thechangelog.com/">The Changelog</a></strong> [<a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=341623264&amp;subMediaType=Audio">itunes</a>] (audio, interview) <a href="http://twitter.com/adamstac">@adamstac</a> and <a href="http://twitter.com/pengwynn">@pengwynn</a><br />
These are the guys behind <a href="http://tail.thechangelog.com/">tail.thechangelog.com</a> and the <a href="http://github.com/explore">github.com/explore</a> pages, and give a great weekly interview with someone in the open source community, and really get into it from the philosophical point of view.  Being able to get a dose of what&#8217;s going on in the Open Source community is definitely an asset and their show (and the opening and closing music) is my Saturday must-have-on-while-driving podcast.</li>
<li><strong><a href="http://37signals.com/podcast">37signals Podcast</a></strong> [<a href="http://itunes.apple.com/WebObjects/MZStore.woa/wa/viewPodcast?id=338108364">itunes</a>] (interview, howto) <a href="http://twitter.com/dhh">@dhh</a> and <a href="http://twitter.com/jasonfried">@jasonfried</a><br />
If you ask for a Rails oriented podcast, how can you not include one from the company that started it all.  This one features DHH and Jason Fried sitting down and talking about all things community, rails and 37signals related.  Sometimes they are just chilling talking about Rails, sometimes it&#8217;s interviewing the sysadmin team, and somtimes it&#8217;s chatting about how the business side of the uhm, business works.  DHH is never one to hide his opinion about things, so it&#8217;s always a great and educational listen.</li>
</ul>
<p>So there you go, hope you enjoy the list and find something new.  Remember though that you don&#8217;t want to get caught up in listening to podcasts about coding, and forget to do the coding yourself.  These will definitely give you a boost of inspiration, training, or just a weekly re-connection with the community.  Also please comment if I&#8217;ve missed any good ones!</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkinginrails.com/2010/04/favorite-ruby-and-rails-podcasts/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Personal Projects For Learning</title>
		<link>http://thinkinginrails.com/2010/04/personal-projects-for-learning/</link>
		<comments>http://thinkinginrails.com/2010/04/personal-projects-for-learning/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 04:39:49 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Help]]></category>
		<category><![CDATA[Resources]]></category>

		<guid isPermaLink="false">http://thinkinginrails.com/?p=285</guid>
		<description><![CDATA[One of the biggest struggles I&#8217;ve had is when learning something starts getting &#8220;stale&#8221;.  It&#8217;s a bit like a relationship, you go from the fun and new &#8220;getting to know you&#8221; stage and eventually plateau into the &#8220;how was your day dear?&#8221; &#8220;grunt&#8221; &#8220;that&#8217;s nice dear&#8221; stage. I plateaued with Perl a while back I [...]]]></description>
			<content:encoded><![CDATA[<p>One of the biggest struggles I&#8217;ve had is when learning something starts getting &#8220;stale&#8221;.  It&#8217;s a bit like a relationship, you go from the fun and new &#8220;getting to know you&#8221; stage and eventually plateau into the &#8220;how was your day dear?&#8221; &#8220;<em>grunt</em>&#8221; &#8220;that&#8217;s nice dear&#8221; stage.</p>
<p>I plateaued with Perl a while back I think, I definitely didn&#8217;t learn anything (I&#8217;m still picking things up from the <a href="http://www.amazon.com/Perl-Best-Practices-Damian-Conway/dp/0596001738">Perl Best Practices</a> book I have), but I found the set of functionality that works for me for 99% of what I need, and that I can manhandle into working for the remaining 1%.  It&#8217;s not a bad thing, but it&#8217;s not a good one either, because I don&#8217;t have the drive to new things with it.</p>
<p>I don&#8217;t think I&#8217;m at that stage with Ruby yet, but I was thinking today on the treadmill about how to avoid that and how to keep things fresh and interesting.  I figure that just like in photography, having a <a href="http://www.yourphototips.com/2008/11/24/start-a-new-personal-photography-project/">Personal Project</a> is a great way to keep things fresh and interesting.  I came up with a few ideas.</p>
<ul>
<li><strong>A Code Sprint</strong> &#8211; They use the term &#8220;sprint&#8221; at my day job to mean a team that is concentrating on getting a new chunk of functionality or application out and done with minimul distraction.  I figure that I can do the same thing, set up a new idea for a site or project and work on <em>nothing but that</em> in my personal coding time (never at the day job of course).  This means when you&#8217;re done the initial fun stuff, database setup, object relationships, etc, you keep on going through the functionality, contact forms, logo, design, etc until it&#8217;s done.  It doesn&#8217;t have to be huge or take a month of your time to do, just make sure you don&#8217;t sit down and say &#8220;you know, adding feature XYZ&#8230; I&#8217;m not feeling it, maybe I&#8217;ll just catch up on Lost some more&#8221; (this is my personal battle right now!)</li>
<li><strong>Learn a Class or Set of Functions <em>Really, Really Well</em></strong> &#8211; Sure it&#8217;ll just be one class (<a href="http://ruby-doc.org/core/classes/Hash.html">Hash</a> for example), or one set of functions (<a href="http://ruby-doc.org/core/classes/Enumerable.html#M003121">grep</a> and array searching for example), and there&#8217;s probably no way to learn <em>everything</em>, but imagine the power to know that you have Hash under your belt, and that you know six ways till Sunday how to search arrays and similar objects, <em>and</em> the best practices and best idioms for it?  And that next week you can choose another class or set of functions to learn.</li>
<li><strong>Answer X Questions A Day</strong> &#8211; The best way to learn I&#8217;ve found is to teach others.  Even if you just know a little bit you can probably bumble your way into some knowledge, and in that way you both learn.  Why not take on a question a day (or 5, or 10) on a forum like the <a href="http://stackoverflow.com/questions/tagged/ruby">StackOverflow ruby</a> questions, or <a href="http://reddit.com/r/ruby">ruby reddit</a>, or the <a href="http://www.ruby-forum.com/forum/4">ruby forums</a>, and fully and completely, to the best of your ability, answer them.  Even if you spend the whole day researching and come up with the same answer that 10 other people have already given, you end up with a greater understanding, and you get to help other people.</li>
<li><strong>Duplicate A Plugin</strong> &#8211; Sure you can just install <a href="http://github.com/technoweenie/restful-authentication">Restful Authentication</a>, or <a href="http://github.com/ryanb/cancan">CanCan</a> for Authorization, or <a href="http://github.com/zargony/activerecord_symbolize">activerecord symbolize</a>, but why not learn what they are actually doing, and create that same core functionality &#8220;by hand&#8221;.  No need to do every nuance of what the plugins do, but creating an auth(entication|orization) system by hand is a great challenge so you know what&#8217;s going on under the hood next time you rely on just running &#8220;script/plugin install&#8230;.&#8221;</li>
</ul>
<p>Those are some good suggestions, what do you other ruby and rails hackers do to learn more or keep yourself sharp?</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkinginrails.com/2010/04/personal-projects-for-learning/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Better Way To Do Dynamic Methods</title>
		<link>http://thinkinginrails.com/2010/04/better-way-to-do-dynamic-methods/</link>
		<comments>http://thinkinginrails.com/2010/04/better-way-to-do-dynamic-methods/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 05:49:50 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Help]]></category>

		<guid isPermaLink="false">http://thinkinginrails.com/?p=242</guid>
		<description><![CDATA[Not sure how best to describe this, so I figure a few lines of code can say a hundred words at least: # app/models/user.rb # This lets me call @user.home_page from within views or controllers to create a URL def home_page if self.referee? return &#34;/bids&#34; # sends user to site.com/bids end if self.assignor? return &#34;/assignors&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>Not sure how best to describe this, so I figure a few lines of code can say a hundred words at least:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># app/models/user.rb</span>
  <span style="color:#008000; font-style:italic;"># This lets me call @user.home_page from within views or controllers to create a URL</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> home_page
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">referee</span>?
      <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#996600;">&quot;/bids&quot;</span> <span style="color:#008000; font-style:italic;"># sends user to site.com/bids</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">assignor</span>?
      <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#996600;">&quot;/assignors&quot;</span> <span style="color:#008000; font-style:italic;"># sends user to site.com/assignors</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#008000; font-style:italic;"># [... etc ...]</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># dynamically determine the role name as a method</span>
  <span style="color:#008000; font-style:italic;"># can this be done to to_sym or something better,</span>
  <span style="color:#008000; font-style:italic;"># or a missing_method call to make it dynamic?</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> referee?
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">role</span>.<span style="color:#9900CC;">name</span>.<span style="color:#9900CC;">downcase</span> == <span style="color:#996600;">&quot;referee&quot;</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">true</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#0000FF; font-weight:bold;">false</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> assignor?
    <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">role</span>.<span style="color:#9900CC;">name</span>.<span style="color:#9900CC;">downcase</span> == <span style="color:#996600;">&quot;assignor&quot;</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">true</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#0000FF; font-weight:bold;">false</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>What I really want to do is call &#8220;bids_path&#8221; or &#8220;assignors_path&#8221;, but those don&#8217;t seem to be available from within the model file.  I&#8217;m sure there must be a better way to do this, from two different aspects:</p>
<ul>
<li> The first part of the code, returning the actual path, or at least the dynamic resource path instead of having it hard coded.  This is possible in the view, but I&#8217;d have to fill it up with checks for the user type and then calling either bids_path for referees or assignors_path for assignors
</li>
<li> The second part, where I create the two methods to make the above determination.  I could just trust that the @user.role.name will return The Right Thing, but I&#8217;m not sure how to auto-magically create the methods to do this for anything that the user.role.name contains.
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://thinkinginrails.com/2010/04/better-way-to-do-dynamic-methods/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Devise Tutorial</title>
		<link>http://thinkinginrails.com/2009/11/devise-tutorial/</link>
		<comments>http://thinkinginrails.com/2009/11/devise-tutorial/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 05:13:10 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Help]]></category>

		<guid isPermaLink="false">http://thinkinginrails.com/?p=74</guid>
		<description><![CDATA[Of course, just after bitching about Devise and how it wasn&#8217;t working, I see an unread post in my RSS on Devise authentication, including a sample app. Will have to play with that tomorrow!]]></description>
			<content:encoded><![CDATA[<p>Of course, just after bitching about Devise and how it wasn&#8217;t working, I see an unread post in my RSS on <a href="http://www.railsinside.com/plugins/351-devise-rails-authentication.html">Devise authentication</a>, including a sample app.</p>
<p>Will have to play with that tomorrow!</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkinginrails.com/2009/11/devise-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Resources</title>
		<link>http://thinkinginrails.com/2009/05/rails-resources/</link>
		<comments>http://thinkinginrails.com/2009/05/rails-resources/#comments</comments>
		<pubDate>Mon, 04 May 2009 05:55:32 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Help]]></category>
		<category><![CDATA[Resources]]></category>

		<guid isPermaLink="false">http://thinkinginrails.com/?p=30</guid>
		<description><![CDATA[As with all noobie learners, one of the best ways to learn about Ruby and Rails is to read sites on the net.  This has it&#8217;s good sides and bad sides.  On the good side, there&#8217;s a vast amount of information out there, free for the taking.  People are willing to throw out information about [...]]]></description>
			<content:encoded><![CDATA[<p>As with all noobie learners, one of the best ways to learn about Ruby and Rails is to read sites on the net.  This has it&#8217;s good sides and bad sides.  On the good side, there&#8217;s a <em>vast</em> amount of information out there, free for the taking.  People are willing to throw out information about coding skills, projects, give you access to their source code&#8230;. all for free.  On the bad side, it&#8217;s the wild west.  There&#8217;s scads of information, mostly unsorted, and a lot of the people sharing it are on the edge of the technology, and it&#8217;s <em>very</em> easy to get lost in the latest-and-greatest and completely miss learning the simple and fundamental lessons.</p>
<p>To quote a game programming book I read once long ago: &#8220;First make it work, then make it work fast.&#8221;  It&#8217;s fairly easy to move that to the ruby world.  &#8220;First write a rails app, then write one with the latest wiz-bang plugin.&#8221;  OK, maybe it doesn&#8217;t work <em>that</em> well <img src='http://thinkinginrails.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here&#8217;s a list of some of the sites I keep in my <a href="http://google.com/reader">RSS reader</a> for keeping up to date&#8230;</p>
<p><span id="more-30"></span><strong>Ruby</strong></p>
<ul>
<li><a href="http://blog.rubybestpractices.com">Ruby Best Practices</a> &#8211; Just found this one, a nice collection of Ruby skills and &#8220;proper&#8221; ways to do it.</li>
<li><a href="http://rubylearning.com/blog/">Ruby Learning Blog</a></li>
<li><a href="http://www.rubyinside.com/">Ruby Inside</a> &#8211; Daily news and links.</li>
<li><a href="http://on-ruby.blogspot.com/">On Ruby</a></li>
</ul>
<p><strong>Ruby on Rails</strong></p>
<ul>
<li><a href="http://railsapi.com/">Rails API</a> &#8211; A web based collection of the Rails API.  See <a href="http://mocra.com/2009/04/24/accessing-rails-documentation-fast/">this site</a> for a great tip on how to integrate this into your local search on a mac if you use <a href="http://www.obdev.at/products/launchbar/index.html">Launchbar</a>.</li>
<li><a href="http://www.railsinside.com/">Rails Inside</a></li>
<li><a href="http://zedshaw.com/blog/index.html">Zed Shaw</a> &#8211; A very notable member of the Rails community, and creator of Mongrel.</li>
<li><a href="http://weblog.jamisbuck.org/">The Bucklogs Here</a></li>
<li><a href="http://ryandaigle.com/">Ryan&#8217;s Scraps</a> &#8211; Lost of the latest news from the edges of Rails and Ruby.</li>
<li><a href="http://weblog.rubyonrails.org/">Riding Rails</a> &#8211; The official RoR weblog.</li>
<li><a href="http://www.railsjedi.com/">Rails Jedi</a> &#8211; How can you <em>not</em> read a blog with this title??</li>
<li><a href="http://rubyplus.org/">Ruby Plus</a> &#8211; Lots more awesome screencasts (though not updated in a while)</li>
</ul>
<p><strong>Podcasts</strong></p>
<ul>
<li><a href="http://railsenvy.com/">Rails Envy</a> &#8211; These guys go through the latest and greatest in the Rails world.  Not a show for the faint hearted though <img src='http://thinkinginrails.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li><a href="http://sdruby.com/podcast/">The SD Ruby Podcast</a> &#8211; Nice screencasts from the Sand Diego Ruby group, a wide variety of topics.</li>
<li><a href="http://railscasts.com/">Railscasts</a> &#8211; Ryan Bates&#8217; awesome snippets of knowledge.  4-10 minute screencasts which nicely wrap up a topic or idea.  <em>Highly</em> recommended.</li>
<li><a href="http://www.buildingwebapps.com/podcasts">Learning Rails</a> &#8211; A series of both audio and video podcasts, starting from &#8220;what is rails&#8221; and eventually building to server deployment, version control, alternate markup languages, etc.</li>
</ul>
<p><strong>Other Misc Tools</strong></p>
<ul>
<li><a href="http://github.com/blog">The GitHub Blog</a></li>
<li><a href="http://blog.heroku.com/">Heroku Blog</a></li>
<li><a href="http://blog.phusion.nl/">Phusion Passenger Blog</a> &#8211; Blog of the apache/rails module</li>
</ul>
<p>That&#8217;s it for now&#8230;  Hopefully some of these will help you out in the quest for knowledge!</p>
]]></content:encoded>
			<wfw:commentRss>http://thinkinginrails.com/2009/05/rails-resources/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

