0

I'm migrating a Rails app from 2.0.2 to 2.3.5.

I have a model class:

class EventQuery < ActiveRecord::Base

  set_table_name 'EventQueries'
  def to_s; name; end

end

I'm debugging the problem in the console. I try to assign an EventQuery object an attribute:

./script/console production Loading production environment (Rails 2.3.5)

>> q=EventQuery.new 
=>  #<EventQuery id: nil, role: nil, name: nil, description: nil, query: nil>
>> q.role="ADM" 
> TypeError: can't convert String into Integer  
from /usr/lib64/ruby/gems/1.8/gem /activerecord-2.3.5/lib/active_record/dirty.rb:135:in `[]='
 (...)

In Rails 2.0.2 it works fine:

./script/console production Loading production environment (Rails 2.0.2)

>> q=EventQuery.new
=> #< EventQuery id: nil, role: nil, name: nil, description: nil, query: nil
>> q.role='ADM'
=> "ADM"

Any ideas? Thank you!

I'm now thinking this must be related to plugin record_modified which is part of the application.

nuno
  • 194
  • 1
  • 11
  • It's simply defined as: `role` char(5) NOT NULL. I get the same error when I try to assign any of the other attributes! – nuno Aug 20 '12 at 14:34
  • >> EventQuery => EventQuery(id: integer, role: string, name: string, description: string, query: text) – nuno Aug 20 '12 at 14:43

1 Answers1

0

This problem is related to a name conflict with a method in the record_modified plugin. The console works fine if I exclude the plugin from loading.

I have decided to remove the record_modified plugin and refactor the code. Instead of using RecordModified methods I'm using ActiveRecord as follows:

RecordModified.modified?  --> ActiveRecord.changed?
RecordModified.changed_columns --> ActiveRecord.changes + minor refactoring
nuno
  • 194
  • 1
  • 11