【发布时间】:2012-08-20 14:12:12
【问题描述】:
我正在将 Rails 应用程序从 2.0.2 迁移到 2.3.5。
我有一个模型类:
class EventQuery < ActiveRecord::Base
set_table_name 'EventQueries'
def to_s; name; end
end
我正在控制台中调试问题。我尝试为 EventQuery 对象分配一个属性:
./script/console 制作 加载生产环境(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 `[]='
(...)
在 Rails 2.0.2 中它可以正常工作:
./script/console 制作 加载生产环境(Rails 2.0.2)
>> q=EventQuery.new
=> #< EventQuery id: nil, role: nil, name: nil, description: nil, query: nil
>> q.role='ADM'
=> "ADM"
有什么想法吗?谢谢!
我现在认为这一定与作为应用程序一部分的插件 record_modified 有关。
【问题讨论】:
-
简单定义为:
rolechar(5) NOT NULL。当我尝试分配任何其他属性时,我得到了同样的错误! -
>> EventQuery => EventQuery(id: integer, role: string, name: string, description: string, query: text)
标签: ruby-on-rails activerecord migrate