<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="color: rgb(248, 248, 248); font-family: 'Bitstream Vera Sans Mono'; font-size: 12px; line-height: 15px; white-space: pre; "><pre class="sunburst" style="font-family: 'Bitstream Vera Sans Mono', Monaco, Courier, monospace; font-size: 9pt; line-height: 1.3em; margin-top: 0em; "><span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby" style="padding-top: 0.2em; padding-bottom: 0.1em; color: rgb(95, 90, 96); font-style: italic; "># psudo-untested-ruby-while-having-coffee code version by chrisfarms</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby" style="padding-top: 0.2em; padding-bottom: 0.1em; color: rgb(95, 90, 96); font-style: italic; ">#</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby" style="padding-top: 0.2em; padding-bottom: 0.1em; color: rgb(95, 90, 96); font-style: italic; "># produces urls like /monkeys/3-your-keywords</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby" style="padding-top: 0.2em; padding-bottom: 0.1em; color: rgb(95, 90, 96); font-style: italic; ">#</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby" style="padding-top: 0.2em; padding-bottom: 0.1em; color: rgb(95, 90, 96); font-style: italic; "># works for SEO, while maintaining all the benifits of a solid numeric ID</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby" style="padding-top: 0.2em; padding-bottom: 0.1em; color: rgb(95, 90, 96); font-style: italic; "># plus points for SEO... if the keywords are changed, 302 redirects will automatically</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby" style="padding-top: 0.2em; padding-bottom: 0.1em; color: rgb(95, 90, 96); font-style: italic; "># move the client to the right page.... solving the duplicate content issue or </span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby" style="padding-top: 0.2em; padding-bottom: 0.1em; color: rgb(95, 90, 96); font-style: italic; "># 404 errors after fixing a typo in a 'slug'</span>
<span class="comment comment_line comment_line_number-sign comment_line_number-sign_ruby" style="padding-top: 0.2em; padding-bottom: 0.1em; color: rgb(95, 90, 96); font-style: italic; ">#</span></pre><pre class="sunburst" style="font-family: 'Bitstream Vera Sans Mono', Monaco, Courier, monospace; font-size: 9pt; line-height: 1.3em; margin-top: 0em; "><font class="Apple-style-span" color="#5F5A60"><i># controller code should be untouched</i></font></pre></span></div><a href="http://pastie.textmate.org/private/gcet24o9er4milpqemjjq">http://pastie.textmate.org/private/gcet24o9er4milpqemjjq</a><div><br class="webkit-block-placeholder"></div><div><br><div><div>On 16 Nov 2007, at 02:26, Michael D. Ivey wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">The original:<br>http://pastie.textmate.org/private/lqvrlyyvkv2kbugoxtiz6w<br><br>Send your submissions to me by email or on #merb. I'll blog it, and <br>pick a winner. The winner does not mean it makes it into Merb, just <br>means I personally like it best.<br><br>But it might make it into Merb.<br><br><br><br># Scenario:<br># You have a simple application that lists all the monkeys at the zoo.<br># Every monkey has a name, and that name is unique.<br># It is currently working.<br>#<br># Your boss comes and asks you to change the "ugly" /monkeys/44 URLs<br># to be "pretty" and "SEO optimized" URLs like /monkeys/koko, with the<br># monkey's name in the URL.<br>#<br># Challenge:<br># Design your perfect API for doing this, using any combination of<br># controller, model, and router changes. Submit it as a diff of this <br>pastie.<br>#<br># Degree of difficulty:<br># Don't complain that doing /monkeys/koko is dumb, or what happens<br># when there are two monkeys named koko.<br>#<br># Submit your diffs to #merb<br><br><br># router:<br>r.resources :monkeys<br><br>class Monkey < MythicalORM<br><br>end<br><br><br>class Monkeys < Application<br> def show(id)<br> @monkey = Monkey.find(id)<br> end<br><br> def create(monkey)<br> @monkey = Monkey.create(monkey)<br> redirect url(:monkey,@monkey)<br> end<br>end<br>_______________________________________________<br>Merb-devel mailing list<br>Merb-devel@rubyforge.org<br>http://rubyforge.org/mailman/listinfo/merb-devel<br></blockquote></div><br></div></body></html>