MongoDB mongo mapper 新建 class 不起作用

itsvoid · September 03, 2012 · Last by itsvoid replied at September 03, 2012 · 2270 hits

我使用的是 mongo mapper,我新建了一个 Model class:

class Book include MongoMapper::Document

key :name, String key :description, String

end

但是数据库里面并没有生成这个 Book 表。怎样才能将新建的 Book 加进数据库呢?

他自己动会加的,你继续玩就行了。有数据过去了他自己知道加

但是我在 collections 里面根本没有看到这个 book

show collections system.indexes users

#1 楼 @ywencn 而且 form_for 也没有自动加 input

#1 楼 @ywencn 有 db:migrate 之类的 refresh 一下吗,还是要重启 server?

#3 楼 @itsvoid 等你 create new book 的时候就会自动创建这个表的

#5 楼 @diudiutang 我是用 rails g scalfold-controller 只创建了 controller,所以 model 文件是我自己手动建的。我需要怎么弄?

#6 楼 @itsvoid 意思是当你 controller 里面执行 create 一个新 book 动作的时候,表会自动创建出来,虽然目前没有这个表

You need to Sign in before reply, if you don't have an account, please Sign up first.