我正在使用 Rails 3.0.6/Ruby 1.8.7,我一直在尝试让acts_as_taggable_on (2.0.6) gem 工作,但默认迁移似乎失败了。日志:
== ActsAsTaggableOnMigration: migrating ======================================
-- create_table(:tags)
-> 0.3175s
-- create_table(:taggings)
rake aborted!
An error has occurred, all later migrations canceled:
Mysql2::Error: Can't create table 'project_development.taggings' (errno: 150):
CREATE TABLE `taggings` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY,
`tag_id` int(11), `taggable_id` int(11), `taggable_type` varchar(255), `tagger_id`
int(11), `tagger_type` varchar(255), `context` varchar(255), `created_at` datetime,
FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`), FOREIGN KEY (`taggable_id`) REFERENCES
`taggables` (`id`), FOREIGN KEY (`tagger_id`) REFERENCES `taggers` (`id`)) ENGINE=InnoDB
所以看起来 :polymorphic => true 属性没有按预期工作。谷歌似乎不是很有帮助(类似的错误报告,例如http://www.ruby-forum.com/topic/194219)。有什么办法解决吗?宝石替代品?
已解决 automatic_foreign_key 与此 gem 冲突