NoMethodError in ClassifiedController#create

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

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.
http://www.railshostinginfo.com
Review and compare Rails hosting companies

I don’t believe it! Thanks mate.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs