Class HTM::Models::NodeTag ¶
| Inherits | Object |
| Defined in | lib/htm/models/node_tag.rb |
NodeTag model - join table for many-to-many relationship between nodes and tags
Public Class Methods¶
link(node_id:, tag_id:) ¶
Link a node to a tag, restoring a soft-deleted link if one exists
The unique index on (node_id, tag_id) covers soft-deleted rows, which the
default scope hides, so find_or_create would try to INSERT a duplicate.
- @param node_id [Integer] Node database ID
- @param tag_id [Integer] Tag database ID
- @return [NodeTag] the active link
Public Instance Methods¶
before_create() ¶
Hooks
deleted?() ¶
Check if entry is soft-deleted
- @return [Boolean] true if deleted_at is set
restore!() ¶
Restore a soft-deleted entry
- @return [Boolean] true if restored successfully
soft_delete!() ¶
Soft delete - mark as deleted without removing from database
- @return [Boolean] true if soft deleted successfully
validate() ¶
Validations