Quick Access
API Reference
Appearance
Path: /admin/commentsNamespace: adminResource: comments
/admin/comments
The Comment resource allows adding notes, annotations, and comments to various resources in the system. Comments support threaded discussions and can be associated with invoices, addresses, items, and other resources.
Comment connects to the following resources:
belongs_to
user_id
user.comments
GET /admin/comments.json?q[user_id_eq]=1
GET /admin/comments.json?q[user_email_cont]=admin
const comments = await fetch('/admin/comments.json?q[user_id_eq]=1', { credentials: 'include', headers: { 'Accept': 'application/json' } }).then(r => r.json());
host_id
domain.comments
GET /admin/comments.json?q[host_id_eq]=1
commentable_type
commentable_id
invoice.comments
address.comments
comment.commentable_type
comment.commentable_id
GET /admin/comments.json?q[commentable_type_eq]=Invoice
GET /admin/comments.json?q[commentable_type_eq]=Address
GET /admin/comments.json?q[commentable_type_eq]=Invoice&q[commentable_id_eq]=123
const invoiceComments = await fetch('/admin/comments.json?q[commentable_type_eq]=Invoice&q[commentable_id_eq]=123', { credentials: 'include', headers: { 'Accept': 'application/json' } }).then(r => r.json());
The following resources can have comments attached (polymorphic):
has_many
commentable
comments
const comments = await fetch('/admin/comments.json?q[commentable_type_eq]=Invoice&q[commentable_id_eq]=123', { credentials: 'include', headers: { 'Accept': 'application/json' } }).then(r => r.json());
GET /admin/comments.json?q[commentable_type_eq]=Address&q[commentable_id_eq]=123
const comments = await fetch('/admin/comments.json?q[commentable_type_eq]=Address&q[commentable_id_eq]=123', { credentials: 'include', headers: { 'Accept': 'application/json' } }).then(r => r.json());
GET /admin/comments.json?q[commentable_type_eq]=Item&q[commentable_id_eq]=123
GET /admin/comments.json?q[commentable_type_eq]=Payment&q[commentable_id_eq]=123
const comment = await fetch('/admin/comments.json', { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify({ comment: { body: 'Please review this invoice before sending', commentable_type: 'Invoice', commentable_id: 123 } }) }).then(r => r.json());
const invoiceComments = await fetch('/admin/comments.json?q[commentable_type_eq]=Invoice', { credentials: 'include', headers: { 'Accept': 'application/json' } }).then(r => r.json());
const userComments = await fetch('/admin/comments.json?q[user_id_eq]=1', { credentials: 'include', headers: { 'Accept': 'application/json' } }).then(r => r.json());
Endpoint: GET /admin/comments.json
GET /admin/comments.json
Query Parameters:
q[field_predicate]=value
page=N
per_page=N
Request Examples:
curl -X GET "https://your-company.erpax.com/admin/comments.json" \ -H "Accept: application/json" \ -H "Cookie: session_cookie"
curl -X GET "https://your-company.erpax.com/admin/comments.json?q[commentable_type_eq]=Invoice&q[commentable_id_eq]=123" \ -H "Accept: application/json"
JavaScript Example:
const response = await fetch('/admin/comments.json', { credentials: 'include', headers: { 'Accept': 'application/json' } }); const data = await response.json();
Response (200 OK):
{ "comments": [ { "id": 1, "body": "Please review this 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": 1, "total_count": 5 } }
Endpoint: GET /admin/comments/:id.json
GET /admin/comments/:id.json
Request Example:
curl -X GET "https://your-company.erpax.com/admin/comments/1.json" \ -H "Accept: application/json" \ -H "Cookie: session_cookie"
{ "comment": { "id": 1, "body": "Please review this invoice", "commentable_type": "Invoice", "commentable_id": 123, "user_id": 1, "created_at": "2024-01-15T10:00:00Z", "updated_at": "2024-01-15T10:00:00Z" } }
Endpoint: POST /admin/comments.json
POST /admin/comments.json
curl -X POST "https://your-company.erpax.com/admin/comments.json" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -H "Cookie: session_cookie" \ -d '{ "comment": { "body": "This invoice needs attention", "commentable_type": "Invoice", "commentable_id": 123 } }'
const response = await fetch('/admin/comments.json', { method: 'POST', credentials: 'include', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify({ comment: { body: 'This invoice needs attention', commentable_type: 'Invoice', commentable_id: 123 } }) }); const comment = await response.json();
Response (201 Created):
{ "comment": { "id": 2, "body": "This invoice needs attention", "commentable_type": "Invoice", "commentable_id": 123, "user_id": 1, "created_at": "2024-01-15T14:30:00Z" } }
Endpoint: PATCH /admin/comments/:id.json
PATCH /admin/comments/:id.json
curl -X PATCH "https://your-company.erpax.com/admin/comments/1.json" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ -H "Cookie: session_cookie" \ -d '{ "comment": { "body": "Updated comment text" } }'
{ "comment": { "id": 1, "body": "Updated comment text", "updated_at": "2024-01-15T15:00:00Z" } }
Endpoint: DELETE /admin/comments/:id.json
DELETE /admin/comments/:id.json
curl -X DELETE "https://your-company.erpax.com/admin/comments/1.json" \ -H "Accept: application/json" \ -H "Cookie: session_cookie"
Response (204 No Content):
(empty response)
No custom scopes are configured (uses default 'all' scope).
Available filters for searching and filtering comments:
/admin/comments
Path:
/admin/commentsNamespace: admin
Resource: comments
Overview
The Comment resource allows adding notes, annotations, and comments to various resources in the system. Comments support threaded discussions and can be associated with invoices, addresses, items, and other resources.
Relationships
Model Associations
Comment connects to the following resources:
User
belongs_toviauser_iduser_iduser.comments)user_idGET /admin/comments.json?q[user_id_eq]=1GET /admin/comments.json?q[user_email_cont]=admin2
3
4
Domain
belongs_toviahost_idhost_iddomain.comments)host_idGET /admin/comments.json?q[host_id_eq]=1Commentable (Polymorphic)
belongs_topolymorphic viacommentable_typeandcommentable_idcommentable_type,commentable_idinvoice.comments,address.comments)comment.commentable_type,comment.commentable_idGET /admin/comments.json?q[commentable_type_eq]=Invoice- Comments on invoicesGET /admin/comments.json?q[commentable_type_eq]=Address- Comments on addressesGET /admin/comments.json?q[commentable_type_eq]=Invoice&q[commentable_id_eq]=123- Comments on specific invoice2
3
4
Reverse Associations
The following resources can have comments attached (polymorphic):
Invoice[]
has_manyon Invoice via polymorphiccommentableassociationGET /admin/comments.json?q[commentable_type_eq]=Invoice&q[commentable_id_eq]=123commentsarray (if present)2
3
4
Address[]
has_manyon Address via polymorphiccommentableassociationGET /admin/comments.json?q[commentable_type_eq]=Address&q[commentable_id_eq]=1232
3
4
Item[]
has_manyon Item via polymorphiccommentableassociationGET /admin/comments.json?q[commentable_type_eq]=Item&q[commentable_id_eq]=123Payment[]
has_manyon Payment via polymorphiccommentableassociationGET /admin/comments.json?q[commentable_type_eq]=Payment&q[commentable_id_eq]=123Relationship Patterns
Creating Comment on Resource
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Filtering Comments by Resource Type
2
3
4
Filtering Comments by Specific Resource
2
3
4
Comments by User
2
3
4
Key Features
Available Operations
List Comments (GET)
Endpoint:
GET /admin/comments.jsonQuery Parameters:
q[field_predicate]=value- Ransack query filters for advanced filteringpage=N- Page number for paginationper_page=N- Items per page (default: 25)Request Examples:
2
3
2
JavaScript Example:
2
3
4
5
Response (200 OK):
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
Show Comment (GET /:id)
Endpoint:
GET /admin/comments/:id.jsonRequest Example:
2
3
Response (200 OK):
2
3
4
5
6
7
8
9
10
11
Create Comment (POST)
Endpoint:
POST /admin/comments.jsonRequest Example:
2
3
4
5
6
7
8
9
10
11
JavaScript Example:
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Response (201 Created):
2
3
4
5
6
7
8
9
10
Update Comment (PATCH /:id)
Endpoint:
PATCH /admin/comments/:id.jsonRequest Example:
2
3
4
5
6
7
8
9
Response (200 OK):
2
3
4
5
6
7
Delete Comment (DELETE /:id)
Endpoint:
DELETE /admin/comments/:id.jsonRequest Example:
2
3
Response (204 No Content):
Scopes
No custom scopes are configured (uses default 'all' scope).
Filters
Available filters for searching and filtering comments:
Business Rules
Related Resources