# Failure in model#new - I don't get it

**URL:** <https://www.ruby-forum.com/t/failure-in-model-new-i-dont-get-it/189718>\
**Category:** Rails\
**Created:** [June 6, 2010, 5:38am UTC](https://www.ruby-forum.com/t/failure-in-model-new-i-dont-get-it/189718 "2010-06-06T05:38:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chewmanfoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c37758/32.png) [@chewmanfoo](https://www.ruby-forum.com/u/chewmanfoo)\
**Post date:** [June 6, 2010, 5:38am UTC](https://www.ruby-forum.com/t/failure-in-model-new-i-dont-get-it/189718/1 "2010-06-06T05:38:31Z")

</div>

Here’s my error:

NameError (undefined local variable or method `gmap\_full\_address’ for  
#Class:0x7f9bae66e788):  
app/models/address.rb:12

here’s the model:

class Address \< ActiveRecord::Base

attr\_accessible :name, :address1, :address2, :city, :state\_id,  
:country\_id, :postal\_code,  
:carrier\_id, :time\_zone, :gmap\_lat, :gmap\_long

…

after\_save {  
logger.info “attempting geocode retrieval for  
#{gmap\_full\_address}” \<------------------  
result = get\_geocode(gmap\_full\_address)  
gmap\_lat = result[:latitude]  
gmap\_long = result[:longitude]  
save  
}

def gmap\_full\_address  
address1 + ", " + city + ", " + state.abbrev  
end

I don’t understand why it’s saying gmap\_full\_address is indefined.

Anyone know why?

---

<div class="post-metadata">

**Author:** ![chewmanfoo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c37758/32.png) [@chewmanfoo](https://www.ruby-forum.com/u/chewmanfoo)\
**Post date:** [June 6, 2010, 11:48am UTC](https://www.ruby-forum.com/t/failure-in-model-new-i-dont-get-it/189718/2 "2010-06-06T11:48:59Z")

</div>

On Jun 6, 4:37 am, chewmanfoo [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> def gmap\_full\_address  
> address1 + ", " + city + ", " + state.abbrev  
> end
> 
> I don’t understand why it’s saying gmap\_full\_address is indefined.
> 
> Anyone know why?

Because you’ve used the block form of after\_save, so self inside that  
block is the class itself, not a particular instance

Fred
