# Restful web service error on saving record

**URL:** <https://www.ruby-forum.com/t/restful-web-service-error-on-saving-record/149373>\
**Category:** Rails\
**Created:** [September 24, 2008, 9:29am UTC](https://www.ruby-forum.com/t/restful-web-service-error-on-saving-record/149373 "2008-09-24T09:29:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![monica](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/a183cd/32.png) [@monica](https://www.ruby-forum.com/u/monica)\
**Post date:** [September 24, 2008, 9:29am UTC](https://www.ruby-forum.com/t/restful-web-service-error-on-saving-record/149373/1 "2008-09-24T09:29:42Z")

</div>

Error is:  
NoMethodError: You have a nil object when you didn’t expect it!  
You might have expected an instance of ActiveRecord::Base.  
The error occurred while evaluating nil.[]  
from /www/gems/gems/activeresource-2.0.2/lib/active\_resource/  
base.rb:817:in `id_from_response' from /www/gems/gems/activeresource-2.0.2/lib/active_resource/ base.rb:804:in `create’  
from /www/gems/gems/activesupport-2.0.2/lib/active\_support/  
core\_ext/object/misc.rb:28:in `returning' from /www/gems/gems/activeresource-2.0.2/lib/active_resource/ base.rb:803:in `create’  
from /www/gems/gems/activeresource-2.0.2/lib/active\_resource/  
base.rb:636:in `save_without_validation' from /www/gems/gems/activeresource-2.0.2/lib/active_resource/ validations.rb:262:in `save’  
from /data/www/rails/authentication/app/models/account.rb:  
89:in `create_notification' from /www/gems/gems/activerecord-2.0.2/lib/active_record/ associations/association_proxy.rb:125:in `send’  
from /www/gems/gems/activerecord-2.0.2/lib/active\_record/  
associations/association\_proxy.rb:125:in `method\_missing’

Client:  
notification\_email.rb model  
class NotificationEmail \< ActiveResource::Base  
self.site = “[[http://mysite](http://mysite)]”  
end

I use the model class to create a new object. Error happens on save.  
def create\_notification  
n = NotificationEmail.new  
n.save  
end

Web service set up is very simple. It basically saves the record to  
the database. I tested it with curl and it works. Anyone has any  
ideas what this error message means?

Thank you!
