Skip to content

/system/comments

Path: /system/comments
Namespace: system
Resource: comments

Overview

The Comment resource in the system namespace provides system administrators with access to comments across all domains for system-wide comment management.

Key Difference from Admin: The system namespace provides cross-tenant access for system administrators, while the admin namespace is scoped to a single domain.

Relationships

See Admin Comments for complete relationship documentation. System comments use the same Comment model with system-wide access.

Available Operations

List Comments (GET)

Endpoint: GET /system/comments.json

Query Parameters:

  • q[field_predicate]=value - Ransack query filters for advanced filtering
  • page=N - Page number for pagination
  • per_page=N - Items per page (default: 25)

Request Examples:

bash
curl -X GET "https://your-company.erpax.com/system/comments.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"

JavaScript Example:

javascript
const response = await fetch('/system/comments.json', {
  credentials: 'include',
  headers: { 'Accept': 'application/json' }
});
const data = await response.json();

Response (200 OK):

json
{
  "comments": [
    {
      "id": 1,
      "body": "This is a comment on an invoice.",
      "commentable_type": "Invoice",
      "commentable_id": 123,
      "user_id": 1,
      "created_at": "2024-01-15T10:00:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 25,
    "total_pages": 5,
    "total_count": 125
  }
}

Show Comment (GET /:id)

Endpoint: GET /system/comments/:id.json

Request Example:

bash
curl -X GET "https://your-company.erpax.com/system/comments/1.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"

JavaScript Example:

javascript
const response = await fetch('/system/comments/1.json', {
  credentials: 'include',
  headers: { 'Accept': 'application/json' }
});
const data = await response.json();

Response (200 OK):

json
{
  "comment": {
    "id": 1,
    "body": "This is a comment on an invoice.",
    "commentable_type": "Invoice",
    "commentable_id": 123,
    "user_id": 1,
    "created_at": "2024-01-15T10:00:00Z",
    "updated_at": "2024-01-15T10:00:00Z"
  }
}

Create Comment (POST)

Endpoint: POST /system/comments.json

Request Example:

bash
curl -X POST "https://your-company.erpax.com/system/comments.json" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie" \
  -d '{
    "comment": {
      "body": "New comment for invoice 123",
      "commentable_type": "Invoice",
      "commentable_id": 123
    }
  }'

JavaScript Example:

javascript
const response = await fetch('/system/comments.json', {
  method: 'POST',
  credentials: 'include',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    comment: {
      body: 'New comment for invoice 123',
      commentable_type: 'Invoice',
      commentable_id: 123
    }
  })
});
const data = await response.json();

Response (201 Created):

json
{
  "comment": {
    "id": 2,
    "body": "New comment for invoice 123",
    "commentable_type": "Invoice",
    "commentable_id": 123,
    "user_id": 1,
    "created_at": "2024-01-15T14:30:00Z"
  }
}

Update Comment (PATCH /:id)

Endpoint: PATCH /system/comments/:id.json

Request Example:

bash
curl -X PATCH "https://your-company.erpax.com/system/comments/1.json" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie" \
  -d '{
    "comment": {
      "body": "Updated comment text."
    }
  }'

JavaScript Example:

javascript
const response = await fetch('/system/comments/1.json', {
  method: 'PATCH',
  credentials: 'include',
  headers: {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  },
  body: JSON.stringify({
    comment: {
      body: 'Updated comment text.'
    }
  })
});
const data = await response.json();

Response (200 OK):

json
{
  "comment": {
    "id": 1,
    "body": "Updated comment text.",
    "updated_at": "2024-01-15T15:00:00Z"
  }
}

Delete Comment (DELETE /:id)

Endpoint: DELETE /system/comments/:id.json

Request Example:

bash
curl -X DELETE "https://your-company.erpax.com/system/comments/1.json" \
  -H "Accept: application/json" \
  -H "Cookie: session_cookie"

JavaScript Example:

javascript
const response = await fetch('/system/comments/1.json', {
  method: 'DELETE',
  credentials: 'include',
  headers: { 'Accept': 'application/json' }
});

Response (204 No Content):

(empty response)

Scopes

See Admin Comments for complete scope documentation. System namespace supports the same scopes as admin namespace, but across all tenants.

Filters

See Admin Comments for complete filter documentation. System namespace supports the same filters as admin namespace, but across all tenants.

Business Rules

  • System-Wide Access: System namespace provides access to all comments across all tenants
  • Cross-Tenant Management: System administrators can manage comments across all tenants
  • Same Business Rules: Follows the same business rules as admin namespace comments

Released under an open source license.