I have the following class in my sinatra app (app.rb)
class Project include DataMapper::Resource property :id, Serial property 开发者_运维知识库:creatorid, Integer, :key => false property :name, String end Project.auto_migrate! unless Project.storage_exists?
and in the post
method, I have:
project = Project.create project.creatorid = GetLoggedInUserId() #returns an int project.name = params['projectname']
But when I'm getting the following error:
no such column: creatorid
(on the project.creatorid
... line)
Suggestions?
You coult try with new
method instead that create
since latter one is used to generate and save an item on the go while the former one is used to generate an empty item that can be then filled (like you do) and then saved with project.save()
.
Take a look at documentation here..
精彩评论