Strange Race Condition?

I have a very odd situation.

I have a method in my application controller:

def manual_location(city, region, country)
result = Location.user_created(params[:new_city],
params[:new_region], params[:new_country])

case result when true then
  return Location.find(:first, :conditions => ["city = ? AND

region = ? AND country = ?", params[:new_city], params[:new_region],
params[:new_country]]).id
when -1 then
flash[:error] = “There was an error saving the location to the
database.”
when false then
flash[:error] = “You didn’t provide all three values: City,
Region, and Country”
end
return false
end

This is the user_created method from the Location model:

def self.user_created(city, region, country)
unless (city && region && country) # Unless we have all three it
is invalid
return false
end

# Either case below it should exist by the time we finish so

return true

check = Location.find(:first, :conditions => ["city = ? AND region

= ? AND country = ?", city, region, country])

if check
  return true
end

location = Location.new(:city => city, :region => region, :country

=> country)

if location.save
  return true
else
  return -1
end

end

When I call the method from one controller it works no problem,
however when I call it from a different contoller I get NilClass
errors.

This doesn’t happen at all on the Windows box I have at work, I only
get the odd behavior on my Linux machine at home.

Does anyone have any ideas?

I realize the model method is ugly, I wrote it late at night and
haven’t gotten around to cleaning it up.