Rails 1.2.5 - : warning: Object#type is deprecated; use Object#class

1 view
Skip to first unread message

CCH

unread,
Oct 17, 2007, 10:26:19 PM10/17/07
to Ruby on Rails: Talk
Hi

After updating to 1.2.5, I am getting
: warning: Object#type is deprecated; use Object#class for this code
snippet

AuditTrail.create(:record_id => record.id, :record_type =>
record.type.name,
:event => event, :user_id
=>user, :name=>username)

Which part of the the above-mentioned code should I change in order to
remove the deprecation warning ?

CCH

unread,
Oct 18, 2007, 12:00:23 AM10/18/07
to Ruby on Rails: Talk
Hi

Have isolated deprecation to :-

:record_type => record.type.name,

How to make this into Object#class syntax ?

William Pratt

unread,
Oct 18, 2007, 12:20:35 AM10/18/07
to rubyonra...@googlegroups.com
You can do record.class. This returns a string representation of the class.

-Bill

Anthony Richardson

unread,
Oct 18, 2007, 12:21:06 AM10/18/07
to rubyonra...@googlegroups.com
CCH wrote:
> Hi
>
> Have isolated deprecation to :-
>
> :record_type => record.type.name,
>
> How to make this into Object#class syntax ?
>
>
Just changing to class instead of type should work, according to the
Ruby docs Object#type is a deprecated synonym for Object#class

:record_type => record.class.name,

http://www.ruby-doc.org/core/classes/Object.html#M000347

CCH

unread,
Oct 18, 2007, 12:39:59 AM10/18/07
to Ruby on Rails: Talk
Hi Anthony

> How to make this into Object#class syntax ?
>
> Just changing to class instead of type should work, according to the
> Ruby docs Object#type is a deprecated synonym for Object#class
>
> :record_type => record.class.name,

cch: This works !
Thanx to you and also Bill Pratt !

Reply all
Reply to author
Forward
0 new messages