Ruby on rails 具有单表继承问题的Rails和Hobo
使用干净的数据库为我的Hobo项目运行Ruby on rails 具有单表继承问题的Rails和Hobo,ruby-on-rails,ruby,migration,single-table-inheritance,hobo,Ruby On Rails,Ruby,Migration,Single Table Inheritance,Hobo,使用干净的数据库为我的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_r
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
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
Setup database.yml,生成并执行迁移:
$ ruby script/generate hobo_migration
$ ruby script/generate hobo_migration
创建第二个模型,B
:
$ruby script/generate hobo_model_resource b
编辑B
模型以扩展A
:
$ ruby script/generate hobo_model_resource a name:string type:string
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
瞧。一切正常。现在,如果我删除所有表并运行db:setup
,它将失败:
$ rake db:setup
...
rake aborted!
Table as does not exist
按照上的建议,我尝试删除test/fixtures/as.yml
和test/fixtures/bs.yml
,但没有任何帮助
流浪汉0.9.103轨道2.3.5
耙0.8.7
jruby 1.4.0RC1
有什么建议吗?我遵循了你的所有步骤,一切都很顺利。您是否尝试过
rake db:schema:load
hobo 0.9.104
rails 2.3.5
rake 0.8.6
ruby 1.8.6
我遵循了你的所有步骤,一切都很顺利。您是否尝试过
rake db:schema:load
hobo 0.9.104
rails 2.3.5
rake 0.8.6
ruby 1.8.6
看起来像是流浪汉里的一只虫子: 据马特·琼斯说: 跟踪具有自动作用域代码,试图查看不带可继承属性的继承的\u是否是一列,这将命中
他死了 他建议加上:
return unless table_exists?
在
列
方法(hobofeelds/lib/hobo\u fields/model\u extensions.rb的第211行)的最开始处。看起来像是hobo中的一个bug:
据马特·琼斯说:
跟踪具有自动作用域代码,试图查看不带可继承属性的继承的\u是否是一列,这将命中他死了 他建议加上:
return unless table_exists?
在
列
方法(hobofeelds/lib/hobo_fields/model_extensions.rb的第211行)的最开始处。请注意,这是在2010年1月24日固定的,并且是在最新的候选版本中。请注意,这是在2010年1月24日固定的,并且是在最新的候选版本中。