把表结构写进model(annotate_models,annotate)

阅读更多

在做ROR开发时,经常要去查schema.rb, 确实有些不便。

 

《Web开发敏捷之道-应用Rails进行敏捷Web开发-第三版》中提到一个插件可将数据库信息添加到model顶端:annotate_models。

 

因为书中所讲内容已是过去时了,已经找不到那个plugn了。

 

google得知:现在有这样的GEM了:

https://github.com/sagework/annotate_models

 

首先安装这个GEM:

gem install annotate
 

然后在Gemfile里添加(重要):

gem 'annotate'

 

到你的ROR app目录下,执行:

annotate

搞定。默认它会把 数据库表结构注释到 model文件的底部。

 

 

你可能感兴趣的:(数据结构,敏捷开发,Rails,Web,Google)