Finding locations with a distance between 1 and 5000
Shorter, and while min/max was tricky, IMO, this is easier to understand:

def self.location(distance=100,location)
    distance = 100 unless distance.is_a?(Integer)
    distance = 1 if distance &lt; 1
    distance = 5000 if distance &gt; 5000

    if location
        within(distance, :origin =&gt; location)
    else  
        find(:all)  
    end  
end