Help with ActiveRecord


#1

Model:

class AdminQueue < ActiveRecord::Base
set_table_name ‘adminqueue’
end

Interacting with it in script/console

AdminQueue.new
=> #<AdminQueue:0x240a910 @attributes={“topic_id”=>nil,
“resolved”=>nil, “updated_on”=>nil, “action”=>nil, “type”=>nil,
“post_id”=>nil, “mod_name”=>nil, “count”=>1, “user_id”=>nil,
“comment”=>nil}, @new_record=true>

AdminQueue.find(:all)
SyntaxError: (eval):1:in compute_type': compile error (eval):1: parse error, unexpected tINTEGER Object::0 ^ from /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1244:incompute_type’
from
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:983:in
instantiate_without_callbacks' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/callbacks.rb:215:ininstantiate’
from
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:in
find_by_sql' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:390:infind_by_sql’
from
/opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:924:in
find_every' from /opt/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:381:infind’
from (irb):7

Any ideas?

Thanks,
PJ


#2

Sorry guys, I meant to post this in the Rails mailing list.

-PJ


#3

Any field named ‘type’ is special in Rails, it enables single table
inheritance and is expected to be a character field. Try renaming the
field to ‘queue_type’ or something along those lines.

Dave


#4

Thanks Dave, I had a naming conflict just yesterday as well, I really
need to pay closer attention.

-PJ