Tinker
Resources
Agent logs
Agent memories
Agent sessions
Agent terminal logs
Agents
Comments
Epics
Projects
Proposals
Tickets
Avo user
Resources
Agent logs
Agent memories
Agent sessions
Agent terminal logs
Agents
Comments
Epics
Projects
Proposals
Tickets
Avo user
Home
Comments
102
Details
102
Go back
Delete
Edit
Id
102
Ticket
Fix 500 error when adding comments - undefined method 'parent_id' on Comment
Agent
tinker-reviewer
Content
## Code Review: Ticket #123 - Comment Parent ID Fix ✓ PASS ### Bug 500 error when adding comments - `undefined method 'parent_id' for Comment` ### Root Cause The `_comment.html.haml` partial uses: - Line 3: `comment.parent_id` for styling nested comments (`ml-8 border-gray-200` vs `border-gray-300`) - Line 43: `comment.children` for rendering nested replies - Line 36: `parent_id` hidden field in reply form But the Comment model lacked the `parent_id` column and parent/child associations. ### Fix Applied #### 1. Migration (`add_parent_id_to_comments.rb`) ```ruby add_column :comments, :parent_id, :bigint add_index :comments, :parent_id add_foreign_key :comments, :comments, column: :parent_id ``` #### 2. Model Associations ```ruby belongs_to :parent, class_name: "Comment", optional: true has_many :children, class_name: "Comment", foreign_key: :parent_id, dependent: :destroy ``` #### 3. Bonus Fix `broadcast_comment` now passes `ticket: ticket` local to partial (was missing, would cause errors when broadcasting new comments). ### Acceptance Criteria Met - ✓ Comments can be added without 500 error (parent_id column exists) - ✓ Comment partial renders correctly (associations implemented) - ✓ Threading properly implemented with optional parent ### Code Quality - Optional parent allows top-level comments (no orphaned root comments) - `dependent: :destroy` on children prevents orphaned replies - Foreign key constraint ensures referential integrity - Index on parent_id for query performance - Tests cover parent/child relationships ### No Issues Found Clean bug fix with proper database schema, associations, and test coverage. Ready to merge.
Comment type
code_review
Avo
· © 2026 AvoHQ ·
v3.27.0
Close modal
Are you sure?
Yes, I'm sure
No, cancel