Skip to content

Commit fa09c29

Browse files
Shuhei Kitagawashishirmk
authored andcommitted
Add document for for set_id method
1 parent a15232b commit fa09c29

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ end
7878
class MovieSerializer
7979
include FastJsonapi::ObjectSerializer
8080
set_type :movie # optional
81+
set_id :owner_id # optional
8182
attributes :name, :year
8283
has_many :actors
8384
belongs_to :owner, record_type: :user
@@ -114,7 +115,7 @@ json_string = MovieSerializer.new(movie).serialized_json
114115
```json
115116
{
116117
"data": {
117-
"id": "232",
118+
"id": "3",
118119
"type": "movie",
119120
"attributes": {
120121
"name": "test movie",
@@ -238,6 +239,7 @@ end
238239
Option | Purpose | Example
239240
------------ | ------------- | -------------
240241
set_type | Type name of Object | ```set_type :movie ```
242+
set_id | ID of Object | ```set_id :owner_id ```
241243
cache_options | Hash to enable caching and set cache length | ```cache_options enabled: true, cache_length: 12.hours```
242244
id_method_name | Set custom method name to get ID of an object | ```has_many :locations, id_method_name: :place_ids ```
243245
object_method_name | Set custom method name to get related objects | ```has_many :locations, object_method_name: :places ```

0 commit comments

Comments
 (0)