我计划在标题,子标题,段落和表格数据的形式中包含大量的用户贡献文本。现在我有适当的belongs_to和has_many关系的标题,子标题和段落的单独模型。在我看来,保存这些用户数据的更理想的解决方案就在那里。我正在寻找另一种工具来有效地将这些信息保存在数据库中。在数据库中保存标题,子标题,段落和表格数据
非常感谢您的帮助。
class Fly < ActiveRecord::Base
has_many :headings
accepts_nested_attributes_for :headings, allow_destroy: true
end
class Heading < ActiveRecord::Base
belongs_to :fly
has_many :subheadings
accepts_nested_attributes_for :subheadings, allow_destroy: true
end
class Subheading < ActiveRecord::Base
belongs_to :heading
has_many :paragraphs
accepts_nested_attributes_for :paragraphs, allow_destroy: true
end
class Paragraph < ActiveRecord::Base
belongs_to :subheading
end
你能解释一下你的意思吗?混乱和非理想?它慢吗?它在视图抽象中没有帮助吗?你也可以向我们展示模型和它们的关联吗? – Anthony 2014-10-15 01:56:17
对我来说,这似乎是一个混乱和不理想的事情,因为将标题/段落/表格形式的用户内容保存到我这里似乎就是这样一种常见现象。我不确定创建单独的模型是否是理想的方法。将在模型和关联中编辑。 – Aventuris 2014-10-15 02:30:56
是的,这是正确的。我正在寻找另一种工具来有效地将这些信息保存在数据库中。 – Aventuris 2014-10-21 16:37:09