Rails shows that an instance of the Comment
model exists, even though the database is empty. My code to show the Comment
is
<% @post.comments.each do |c| %>
<%= c %>
<% end %>
And from that, I get #<Comment:0x007fe971c02800>
, but the table has no records. If I change that code to
<% @post.comments.each do |c| %>
<%= c.body %>
<% end %>
I get nothing. Maybe it has something to me using closure_tree
. If it helps, here is the schema for the table:
create_table "comment_hierarchies", id: false, force: true do |t|
t.integer "ancestor_id", null: false
t.integer "descendant_id", null: false
t.integer "generations", null: false
end
add_index "comment_hierarchies", ["ancestor_id", "descendant_id", "generations"], name: "comment_anc_desc_udx", unique: true
add_index "comment_hierarchies", ["descendant_id"], name: "comment_desc_idx"
create_table "comments", force: true do |t|
t.string "body"
t.string "author"
t.string "post_id"
t.boolean "deleted"
t.boolean "locked"
t.datetime "created_at"
t.datetime "updated_at"
end
Aucun commentaire:
Enregistrer un commentaire