# NoMethodError in ClassifiedController#create

**URL:** <https://www.ruby-forum.com/t/nomethoderror-in-classifiedcontroller-create/84051>\
**Category:** Rails\
**Created:** [January 31, 2007, 8:34pm UTC](https://www.ruby-forum.com/t/nomethoderror-in-classifiedcontroller-create/84051 "2007-01-31T20:34:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![doucie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71c47a/32.png) [@doucie](https://www.ruby-forum.com/u/doucie)\
**Post date:** [January 31, 2007, 8:34pm UTC](https://www.ruby-forum.com/t/nomethoderror-in-classifiedcontroller-create/84051/1 "2007-01-31T20:34:12Z")

</div>

Hope you can help. Getting the error message

NoMethodError in ClassifiedController#create  
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.save

Here’s my controller code. I’m totally new to ruby on rails so help  
would be much appreciated

class ClassifiedController \< ApplicationController  
def list  
@classifieds=Classified.find(:all)  
end

def show  
@classified=Classified.find(params[:id])  
end

def new  
@classified=Classified.new  
end

def create  
@classifed=Classified.new(params[:classified])  
if @classified.save  
redirect\_to :action =\>‘list’  
else  
render :action =\>‘new’  
end  
end

---

<div class="post-metadata">

**Author:** ![doucie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71c47a/32.png) [@doucie](https://www.ruby-forum.com/u/doucie)\
**Post date:** [January 31, 2007, 9:01pm UTC](https://www.ruby-forum.com/t/nomethoderror-in-classifiedcontroller-create/84051/2 "2007-01-31T21:01:02Z")

</div>

Don’t know if you copy pasted the code above, but I think you are  
getting this error because you have a typo at:

@classifed=Classified.new(params[:classified])

@classifed should be @classified

Kind regards,

Nick S.

> **[Ruby on Rails hosting companies - Compare, review and find your next ROR host](https://www.railshostinginfo.com/)**
>
> Are you looking for a good and reliable Ruby on Rails hosting company? We have lined them up so you can easily compare and review them.

Review and compare Rails hosting companies

---

<div class="post-metadata">

**Author:** ![doucie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/71c47a/32.png) [@doucie](https://www.ruby-forum.com/u/doucie)\
**Post date:** [January 31, 2007, 9:41pm UTC](https://www.ruby-forum.com/t/nomethoderror-in-classifiedcontroller-create/84051/3 "2007-01-31T21:41:50Z")

</div>

I don’t believe it! Thanks mate.
