MySQL2 缺少方法
当我安装适配器时,为什么此方法 (list_id) 未定义?
== XXXXX: migrating ========================================
-- create_table(:XXXX)
-- list_id()
rake aborted!
An error has occurred, all later migrations canceled:
undefined method `list_id' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x007f8345fc0f10>
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:385:in `block in method_missing'
这是满载:
undefined method `list_id' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x007f9a3d416340>
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:385:in `block in method_missing'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:361:in `block in say_with_time'
/Users/dcarpenter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:295:in `measure'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:361:in `say_with_time'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:381:in `method_missing'
/Users/dcarpenter/Dropbox/workspace/BlueFusion/db/migrate/20110812030512_create_outreach_campaigns.rb:4:in `block in up'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/schema_statements.rb:157:in `create_table'
/Users/dcarpenter/Dropbox/workspace/gems/mysql2-0.2.11/lib/active_record/connection_adapters/mysql2_adapter.rb:421:in `create_table'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:385:in `block in method_missing'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:361:in `block in say_with_time'
/Users/dcarpenter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:295:in `measure'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:361:in `say_with_time'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:381:in `method_missing'
/Users/dcarpenter/Dropbox/workspace/BlueFusion/db/migrate/20110812030512_create_outreach_campaigns.rb:3:in `up'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:314:in `block in migrate'
/Users/dcarpenter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:295:in `measure'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:314:in `migrate'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:397:in `migrate'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:539:in `block (2 levels) in migrate'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:615:in `call'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:615:in `ddl_transaction'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:538:in `block in migrate'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:525:in `each'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:525:in `migrate'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:435:in `up'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:417:in `migrate'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/railties/databases.rake:142:in `block (2 levels) in <top (required)>'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/dcarpenter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/Users/dcarpenter/.rvm/rubies/ruby-1.9.2-p290/bin/rake:19:in `load'
/Users/dcarpenter/.rvm/rubies/ruby-1.9.2-p290/bin/rake:19:in `<main>'
class CreateOutreachCampaigns < ActiveRecord::Migration
def self.up
create_table :outreach_campaigns do |t|
t.integer list_id
t.integer parent_list_id
t.integer survey_id
t.integer user_id
t.string short_desc
t.string long_desc
t.enum type, :limit => [:call,:walk]
t.timestamps
end
add_index "outreach_campaigns", ["list_id"]
add_index "outreach_campaigns", ["survey_id"]
add_index "outreach_campaigns", ["parent_list_id"]
add_index "outreach_campaigns", ["user_id"]
end
def self.down
drop_table :outreach_campaigns
end
end
Why would this method (list_id) be undefined when I have the adapter installed?
== XXXXX: migrating ========================================
-- create_table(:XXXX)
-- list_id()
rake aborted!
An error has occurred, all later migrations canceled:
undefined method `list_id' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x007f8345fc0f10>
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:385:in `block in method_missing'
HERE'S THE FULL LOAD:
undefined method `list_id' for #<ActiveRecord::ConnectionAdapters::Mysql2Adapter:0x007f9a3d416340>
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:385:in `block in method_missing'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:361:in `block in say_with_time'
/Users/dcarpenter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:295:in `measure'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:361:in `say_with_time'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:381:in `method_missing'
/Users/dcarpenter/Dropbox/workspace/BlueFusion/db/migrate/20110812030512_create_outreach_campaigns.rb:4:in `block in up'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/connection_adapters/abstract/schema_statements.rb:157:in `create_table'
/Users/dcarpenter/Dropbox/workspace/gems/mysql2-0.2.11/lib/active_record/connection_adapters/mysql2_adapter.rb:421:in `create_table'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:385:in `block in method_missing'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:361:in `block in say_with_time'
/Users/dcarpenter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:295:in `measure'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:361:in `say_with_time'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:381:in `method_missing'
/Users/dcarpenter/Dropbox/workspace/BlueFusion/db/migrate/20110812030512_create_outreach_campaigns.rb:3:in `up'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:314:in `block in migrate'
/Users/dcarpenter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:295:in `measure'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:314:in `migrate'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:397:in `migrate'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:539:in `block (2 levels) in migrate'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:615:in `call'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:615:in `ddl_transaction'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:538:in `block in migrate'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:525:in `each'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:525:in `migrate'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:435:in `up'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/migration.rb:417:in `migrate'
/Users/dcarpenter/Dropbox/workspace/gems/activerecord-3.0.9/lib/active_record/railties/databases.rake:142:in `block (2 levels) in <top (required)>'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:205:in `call'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:205:in `block in execute'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:200:in `each'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:200:in `execute'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/dcarpenter/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/task.rb:144:in `invoke'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:112:in `invoke_task'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:90:in `block (2 levels) in top_level'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:90:in `each'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:90:in `block in top_level'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:84:in `top_level'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:62:in `block in run'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/dcarpenter/Dropbox/workspace/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/Users/dcarpenter/.rvm/rubies/ruby-1.9.2-p290/bin/rake:19:in `load'
/Users/dcarpenter/.rvm/rubies/ruby-1.9.2-p290/bin/rake:19:in `<main>'
class CreateOutreachCampaigns < ActiveRecord::Migration
def self.up
create_table :outreach_campaigns do |t|
t.integer list_id
t.integer parent_list_id
t.integer survey_id
t.integer user_id
t.string short_desc
t.string long_desc
t.enum type, :limit => [:call,:walk]
t.timestamps
end
add_index "outreach_campaigns", ["list_id"]
add_index "outreach_campaigns", ["survey_id"]
add_index "outreach_campaigns", ["parent_list_id"]
add_index "outreach_campaigns", ["user_id"]
end
def self.down
drop_table :outreach_campaigns
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
第 4 行应该是 t.integer :list_id。其余行也有同样的错误。
另请注意,枚举列需要 插件 并且名为“type”的列是一个坏主意,因为类型是保留字,您可以绕过它,但最好将该列重命名为其他名称。
It should be
t.integer :list_id
on line 4. Rest of the lines have the same mistake.Also note that the enum-column requires a plugin and column called "type" is a bad idea because type is a reserved word, you can get around it, but you're better off renaming the column to something else.