mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-23 06:16:50 +00:00
adding ruby tag to code blocks
This commit is contained in:
parent
558769981e
commit
6a8da1f664
@ -2,7 +2,7 @@
|
||||
|
||||
Let's say you have a basic Post Controller:
|
||||
|
||||
```
|
||||
```ruby
|
||||
class PostController < ApplicationController
|
||||
def dashboard
|
||||
render json: @posts
|
||||
@ -12,7 +12,7 @@ end
|
||||
|
||||
Odds are, your serializer will look something like this:
|
||||
|
||||
```
|
||||
```ruby
|
||||
class PostSerializer < ActiveModel::Serializer
|
||||
attributes :id, :title, :body
|
||||
end
|
||||
@ -23,7 +23,7 @@ into the serializer. Here's what you would do:
|
||||
|
||||
### posts_controller.rb
|
||||
|
||||
```
|
||||
```ruby
|
||||
...
|
||||
def dashboard
|
||||
render json: @posts, user_id: 12
|
||||
@ -33,7 +33,7 @@ into the serializer. Here's what you would do:
|
||||
|
||||
### posts_serializer.rb
|
||||
|
||||
```
|
||||
```ruby
|
||||
...
|
||||
def comments_by_me
|
||||
Comments.where(user_id: instance_options[:user_id], post_id: object.id)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user