# psudo-untested-ruby-while-having-coffee code version by chrisfarms
#
# produces urls like /monkeys/3-your-keywords
#
# works for SEO, while maintaining all the benifits of a solid numeric ID # plus points for SEO... if the keywords are changed, 302 redirects will automatically # move the client to the right page.... solving the duplicate content issue or
# 404 errors after fixing a typo in a 'slug'
#
# controller code should be untouched
http://pastie.textmate.org/private/gcet24o9er4milpqemjjq


On 16 Nov 2007, at 02:26, Michael D. Ivey wrote:

The original:
http://pastie.textmate.org/private/lqvrlyyvkv2kbugoxtiz6w

Send your submissions to me by email or on #merb.  I'll blog it, and
pick a winner.  The winner does not mean it makes it into Merb, just
means I personally like it best.

But it might make it into Merb.



# Scenario:
# You have a simple application that lists all the monkeys at the zoo.
# Every monkey has a name, and that name is unique.
# It is currently working.
#
# Your boss comes and asks you to change the "ugly" /monkeys/44 URLs
# to be "pretty" and "SEO optimized" URLs like /monkeys/koko, with the
# monkey's name in the URL.
#
# Challenge:
# Design your perfect API for doing this, using any combination of
# controller, model, and router changes.  Submit it as a diff of this
pastie.
#
# Degree of difficulty:
# Don't complain that doing /monkeys/koko is dumb, or what happens
# when there are two monkeys named koko.
#
# Submit your diffs to #merb


# router:
r.resources :monkeys

class Monkey < MythicalORM

end


class Monkeys < Application
  def show(id)
    @monkey = Monkey.find(id)
  end

  def create(monkey)
    @monkey = Monkey.create(monkey)
    redirect url(:monkey,@monkey)
  end
end
_______________________________________________
Merb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/merb-devel

_______________________________________________
Merb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/merb-devel

Reply via email to