当我使用干净的数据库为我的Hobo项目运行db:setup时,我得到了一个错误。我有两个模型,A和B,其中B通过单表继承扩展了A。创造一切都是可行的。但是如果我从一个新的数据库开始,rake会失败,并显示一个错误:
$ rake db:setup
...
rake aborted!
Table as does not exist以下是我重现它所经历的步骤。首先,创建Hobo应用程序:
$ hobo testproject创建第一个模型A
$ ruby script/generate hobo_model_resource a name:string type:string设置database.yml,生成并执行迁移:
$ ruby script/generate hobo_migration创建第二个模型B
$ruby script/generate hobo_model_resource b编辑B模型以扩展A
class B < A
# --- Permissions --- #
def create_permitted?
acting_user.administrator?
end
def update_permitted?
acting_user.administrator?
end
def destroy_permitted?
acting_user.administrator?
end
def view_permitted?(field)
true
end
end生成并运行迁移:
$ ruby script/generate hobo_migration瞧。一切正常。现在,如果我删除所有表并运行db:setup,它将失败:
$ rake db:setup
...
rake aborted!
Table as does not exist按照Ruby on Rails Single Table Inheritance (STI) and unit test problem (with PostgreSQL)的建议,我尝试删除了test/fixtures/as.yml和test/fixtures/bs.yml,但没有任何帮助。
流浪汉0.9.103
rails 2.3.5
rake 0.8.7
jruby 1.4.0RC1
有什么建议吗?
发布于 2010-01-23 23:44:24
看起来像是Hobo中的一个bug:
http://groups.google.com/group/hobousers/browse_thread/thread/2160e78762791946
根据马特·琼斯的说法:
跟踪让自动作用域代码尝试查看inherited_without_inheritable_attributes是否是列,这将命中
DB和。
他建议添加以下内容:
return unless table_exists? 在column方法的最开始(hobofields/lib/hobo_fields/model_extensions.rb的第211行)。
发布于 2010-01-23 06:32:43
我遵循了你的所有步骤,一切都很顺利。你试过rake db:schema:load吗?
hobo 0.9.104
rails 2.3.5
rake 0.8.6
ruby 1.8.6https://stackoverflow.com/questions/2113881
复制相似问题