File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 22
33Let's say you have a basic Post Controller:
44
5- ```
5+ ``` ruby
66class PostController < ApplicationController
77 def dashboard
88 render json: @posts
1212
1313Odds are, your serializer will look something like this:
1414
15- ```
15+ ``` ruby
1616class PostSerializer < ActiveModel ::Serializer
1717 attributes :id , :title , :body
1818end
@@ -23,7 +23,7 @@ into the serializer. Here's what you would do:
2323
2424### posts_controller.rb
2525
26- ```
26+ ``` ruby
2727...
2828 def dashboard
2929 render json: @posts , user_id: 12
@@ -33,7 +33,7 @@ into the serializer. Here's what you would do:
3333
3434### posts_serializer.rb
3535
36- ```
36+ ``` ruby
3737...
3838 def comments_by_me
3939 Comments .where(user_id: instance_options[:user_id ], post_id: object.id)
You can’t perform that action at this time.
0 commit comments