2
我有像年权#2,#年权3(可怕的)列名的遗留表...年权#9列名
我建立一个模型,它起名Glamas
如果我有:
accounts = Glamas.all
account_mains = accounts.collect(&:ACCOUNT_MAIN)
它打破了这个错误:
SyntaxError: compile error
/usr/lib/ruby/gems/1.8/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:273: syntax error, unexpected kUNDEF, expecting ')'
undef :LYEAR#9?
^
/usr/lib/ruby/gems/1.8/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:274: syntax error, unexpected kEND, expecting $end
from /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:274:in `define_attribute_methods'
from /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:262:in `each'
from /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:262:in `define_attribute_methods'
from /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:261:in `each'
from /usr/lib/ruby/gems/1.8/gems/activemodel-3.0.3/lib/active_model/attribute_methods.rb:261:in `define_attribute_methods'
from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/attribute_methods.rb:13:in `define_attribute_methods'
from /usr/lib/ruby/gems/1.8/gems/activerecord-3.0.3/lib/active_record/attribute_methods.rb:41:in `method_missing'
from (irb):31:in `to_proc'
from (irb):31:in `collect'
from (irb):31
from :0
这是一个有问题的activemodel,还是我可以用我的代码中的某些东西修复的东西?
这是轨道3 btw。
#glamas.rb
class Glamas < ActiveRecord::Base
establish_connection "turnkey"
end
和...
#database.yml
turnkey:
adapter: mysql
encoding: utf8
reconnect: false
database: turnkey
pool: 5
username: root
password:
socket: /var/run/mysqld/mysqld.sock
我从旧机拉表海峡过来,我想(如果我绝对有),当我拉他们了,我可以重命名列,但这个过程已经是一个巨大的痛苦和处理器密集型。
你是如何声明表映射的? – Dogbert 2011-01-11 23:00:37
更新了此信息的问题。 – 2011-01-11 23:05:09