# Error in validation

**URL:** <https://www.ruby-forum.com/t/error-in-validation/125350>\
**Category:** Rails\
**Created:** [January 8, 2008, 1:57pm UTC](https://www.ruby-forum.com/t/error-in-validation/125350 "2008-01-08T13:57:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![venu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/9de0a6/32.png) [@venu](https://www.ruby-forum.com/u/venu)\
**Post date:** [January 8, 2008, 1:57pm UTC](https://www.ruby-forum.com/t/error-in-validation/125350/1 "2008-01-08T13:57:59Z")

</div>

# I have the following model

class SoftwareCi \< ActiveRecord::Base  
has\_one :ci, :as =\> :content  
has\_one :primary\_group  
validates\_presence\_of :name, :message =\> “can’t be empty”  
end

# The controller

def create  
@software\_ci= SoftwareCi.new(params[:ci])  
redirect\_to :action =\> ‘create\_ui’

end

# The rhtml, create\_ui, I have given the following

\<% unless @software\_ci.errors.empty? %\>  
Error occurred!

 \<% @software\_ci.errors.each\_full do |message| %\> - \<%= message %\>
 \<% end %\> 
\<% end %\>
# The problem

I get the following error in the view

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.errors

Could you please help me?
