ruby 2.0.0p247
Rails 3.2.22
MySQL的
我添加了gem' annotate' 捆绑安装后。宝石已安装
下一步:rails g annotate:install
下一步:运行rake db:migrate
显示错误:
无法注释app / models / blog_post.rb:未定义的方法`supports_foreign_keys?' for ActiveRecord :: ConnectionAdapters :: Mysql2Adapter:0x0000000346aae8
与其他模型类似
有什么不对?如何解决这个问题。谢谢。
修改
shema.rb
.........................
create_table "blog_posts", :force => true do |t|
t.integer "user_id", :null => false
t.string "subject"
t.text "body", :null => false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "comments_count", :default => 0, :null => false
t.boolean "delta", :default => true, :null => false
t.string "tags_line"
t.string "commentable_by", :default => "all", :null => false
t.string "visible_by", :default => "all", :null => false
t.integer "article_id"
t.boolean "draft", :default => false, :null => false
t.datetime "published_at"
t.datetime "last_comment_at"
end
add_index "blog_posts", ["delta"], :name => "index_blog_posts_on_delta"
add_index "blog_posts", ["user_id"], :name => "index_blog_posts_on_user_id"
........................................................................
答案 0 :(得分:1)
您的annotate-gem和mysql2-gem的版本可能不兼容。您仍在使用Rails 3.2。也许是因为你的mysql2-gem很老了。 查看annotate-gem的release notes时,可以看到它在2.6.9中添加了foreign_key支持。所以它可以帮助降级到2.6.8