# More deprecation warnings

**URL:** <https://www.ruby-forum.com/t/more-deprecation-warnings/194074>\
**Category:** Rails\
**Created:** [August 29, 2010, 9:15pm UTC](https://www.ruby-forum.com/t/more-deprecation-warnings/194074 "2010-08-29T21:15:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bruparel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e47774/32.png) [@bruparel](https://www.ruby-forum.com/u/bruparel)\
**Post date:** [August 29, 2010, 9:15pm UTC](https://www.ruby-forum.com/t/more-deprecation-warnings/194074/1 "2010-08-29T21:15:59Z")

</div>

How can I fix the following code for deprecation warning?

def correct\_client\_assignment  
role = Role.find\_by\_name(‘eclient’)  
if client\_id.blank? && role\_id == role.id  
errors.add :client\_id, “must assign an external client to this  
user”  
elsif !client\_id.blank? && role\_id != role.id  
errors.add :client\_id, “cannot assign an internal user to a  
client”  
end  
end

It is the errors.add part that is triggering the following messages:

…DEPRECATION WARNING: Errors#on have been  
deprecated, use Errors#[] instead.  
Also note that the behaviour of Errors#[] has changed. Errors#[] now  
always returns an Array. An empty Array is returned when there are no  
errors on the specified attribute. (called from on at  
/home/bruparel/.rvm/gems/ruby-1.9.2-p0/gems/activemodel-3.0.0.rc2/lib/active\_model/deprecated\_error\_methods.rb:7)

Thanks.

Bharat
