Using saved object in same controller

Hi, I'm having a bit of an IF-statement-problem that produces a
NoMethodError if it's included in my method, although there is a
corresponding column in my table. What I want to do is check if an
record exists, or else I would like to create a new one based on
previously defined variables in my method.

def ait
  @country = 'Some place warm'
  @location = Location.find_by_adress(@requested_adress)
  if @location = nil
    @new_location =
    @new_location.adress = @requested_adress = @hostname
    @location = @location_ip
  render :text =>

Without the if-statement, it all works fine but when it's included I

NoMethodError in TestsController#cached_hostname_reaction
You have a nil object when you didn't expect it!
The error occurred while evaluating

It seems to me that I'm missing some fundamental Ruby-aspect, but I
can't figure out what...

Many thanks!

if @location.nil?

not if @location = nil