File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,10 +16,6 @@ And then execute:
1616```
1717$ bundle
1818```
19- Or install it manually as:
20- ```
21- $ gem install jsonapi-rails
22- ```
2319
2420## Usage
2521
@@ -28,29 +24,28 @@ $ gem install jsonapi-rails
2824Example:
2925``` ruby
3026# app/serializable/serializable_user.rb
31- class SerializableUser < JSONAPI ::Serializable ::Model
27+ class SerializableUser < JSONAPI ::Serializable ::Resource
3228 type ' users'
3329
3430 attribute :name
3531 attribute :email do
36- " #{ @model .name} @foo.bar"
32+ " #{ @object .name} @foo.bar"
3733 end
3834
3935 has_many :posts do
40- # data is auto-inferred
41- link(:related ) { @url_helpers .user_posts(@model ) }
36+ link(:related ) { @url_helpers .user_posts(@object ) }
4237 meta foo: :bar
4338 end
4439
4540 has_many :comments do
46- data do
41+ resources do
4742 @user .comments.order(:desc )
4843 end
4944 end
5045
5146 has_many :reviews , Foo ::Bar ::SerializableRev
5247
53- link(:self ) { @url_helpers .user_url(@model .id) }
48+ link(:self ) { @url_helpers .user_url(@object .id) }
5449 meta do
5550 { foo: ' bar' }
5651 end
You can’t perform that action at this time.
0 commit comments