Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sqlite在多态性中没有给出这样的列错误,这有很多缺点_Sqlite_Ruby On Rails 4 - Fatal编程技术网

Sqlite在多态性中没有给出这样的列错误,这有很多缺点

Sqlite在多态性中没有给出这样的列错误,这有很多缺点,sqlite,ruby-on-rails-4,Sqlite,Ruby On Rails 4,我不确定这是否是sqlite的一个错误,但我在其他项目中也遇到过这种情况,现在我遇到了一个错误,场景如下。 我有一个类别表,模型如下: class Category < ActiveRecord::Base has_many :tags end class Tag < ActiveRecord::Base belongs_to :categorizable, polymorphic: true belongs_to :category end 我的db/schema.rb

我不确定这是否是sqlite的一个错误,但我在其他项目中也遇到过这种情况,现在我遇到了一个错误,场景如下。 我有一个类别表,模型如下:

class Category < ActiveRecord::Base
  has_many :tags
end
class Tag < ActiveRecord::Base
 belongs_to :categorizable, polymorphic: true
 belongs_to :category
end

我的db/schema.rb文件显示了tags表的categorizable_id和categorizable_type列,所以我的问题是,为什么sqlite找不到它们?

我不确定我会有多大帮助,因为我目前正与相同的错误作斗争,但我注意到一件事是在您拼写错误的categorizable问题类中

你在哪里

应该是

不确定这是否是最终解决方案,但希望是朝着正确方向迈出的一步

class Question < ActiveRecord::Base
 has_many :tags, as: :categoryzable
 has_many :categories, through: :tags
end
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: tags.categoryzable_id: SELECT "tags".* FROM "tags" WHERE "tags"."categoryzable_id" = ? AND "tags"."categoryzable_type" = ?
class Question < ActiveRecord::Base
 has_many :tags, as: :categoryzable
 ...
end
class Question < ActiveRecord::Base
 has_many :tags, as: :categorizable
  ...
end