Read my latest article: 8 things I look for in a Ruby on Rails app (posted Thu, 06 Jul 2017 17:59:00 GMT), worth the wait?

Posted by Wed, 16 Mar 2005 13:58:19 GMT

Some people are discussing RubyURL on the Ruby-Talk mailing list on ways to know where you will go before clicking on the link..or before getting to the destination url.

Hal Futon suggested this method:

..but I think that would be too long of a URL for things with longer urls than

My suggestion/compromise would be the following: User clicks on rubyurl link, is taken to page that shows the page they will be redirected to (or even just the domain name) and they wait for a few seconds before it redirects. During this time they could opt-out of allowing the redirect and click a ‘Back’ button.

What do you think? I am open to suggestions on to best address this concern..or is it even a concern? (tinyurl doesn’t think it is..or at least they don’t do, should RubyURL?)


Minor RubyURL update

Posted by Tue, 15 Mar 2005 22:41:06 GMT

I added a check to rubyurl so that it will reuse an existing short_url rather than creating unique urls for every entry. (there are 21 entries for slashdot.. heh)

Hoping to add the filter checks later so that you don’t get the error page when you try to add something like ‘’ into the system.


Ruby Syntax HIghlighting in your blog

Posted by Tue, 15 Mar 2005 20:45:55 GMT

Carl of posted on the Rails list a link to his ruby syntax highliter page. You can paste your ruby code in a textarea and it generates HTML-friendly syntax of your code so that you can style it with css.

I will try to get this to work in Typo sometime today. :-) was it destiny?

Posted by Tue, 15 Mar 2005 05:16:58 GMT

After announcing RubyURL (almost 200 URLs in 12 hours!), I saw a thread on RubyTalk discussing TinyURL and saw a post from Friday..where someone suggested the idea of a site called,!

Here’s the weird part. I subscribed to RubyTalk yesterday (Sunday morning) and never saw that thread, never saw that suggestion..and somehow, I came up with this idea to build last night (as a let’s see if I can do it in a hour’ type of project).

However, now that I just saw the thread, I feel like I unknowingly took someones idea and ran with it..without ever knowing it. heh.

As I just said on RubyTalk, the world works in strange ways…

RubyURL gets a few filters

Posted by Mon, 14 Mar 2005 17:11:12 GMT

heading to bed.. (finally)

A few people thought they were funny. heh

I’ll work on adding some better error checking tomorrow. I just happen to know how to do it quicker in PostgreSQL.

ALTER TABLE rubyurls ADD CONSTRAINT url_exclude 
    website_url !~ 'goatse' AND 
    website_url !~ '' AND 
    website_url !~ 'tubgirl'); in a hour...

Posted by Mon, 14 Mar 2005 16:27:51 GMT

Ok, I will admit it. I spent much longer than a hour on this. I spent about a hour coding, testing and adding a few CSS tags to the few pages. I spent a few hours trying to figure out why my RewriteRule was not working.

At about 10pm on Sunday evening, I had an idea… hey, I’ll spend the rest of the night on a simple Rails project… and after being sent a link for a tinyurl, I thought, Hey, I’ll just create So, I checked, the domain was available and I will now own it until this time next year.

The system thus far comprises of 1 database table, 2 controllers and 1 model that were added to the default rails install. (not including the Rails templates for new.rhtml and show.rhtml).

The random character string function that I used is here: This allos me to create some random alpha-numeric string like ur029
class Rubyurl < ActiveRecord::Base

  def self.gen_random(size=5)
    chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890" 
    short_url = "" 
    size.times do
      pos = rand(chars.length)
      short_url += chars[pos..pos]

So, with the standard usage of scaffold I was able to create a random string prior to saving my form:
  def create
    @rubyurl =['rubyurl'])
    @rubyurl['short_url'] = Rubyurl.gen_random(5)
      flash['notice'] = 'Rubyurl was successfully created.'
      redirect_to :action => 'show', :id =>
      render_action 'new'

The last part in the ruby code was to make it actually redirect to another location:

class GoController < ApplicationController

  scaffold :rubyurl

  def go

  def index
    @url = Rubyurl.find_first(["short_url = ?", @params["id"]])
    if @url['website_url']
      redirect_to @url['website_url']


... so just over 2 1/2 hours later (mainly due to a problem with the RewriteRule..), I am now happy to announce the alpha release of RubyURL.

I’ll write more about my findings when I wake up.. off to bed.

Older posts: 1 ... 96 97 98 99