1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ActiveRecordSerializerのScope

Last updated at Posted at 2017-10-16

#ActiveModelSerialzerで詰まったところ

scopeって何?

どうやらデフォルトではcurrent_userらしい。 (devise環境下)

場合分け

attribute :email, if: :admin?

def admin?
    scope.admin?
end

みたいにする

attributes :id, :email, if: :admin?

だとできなかった。 if: :admin?{:if => :admin?} と認識される。

REST

indexとかshowとかで出力を分けたい時ってどうすればいいんですかね。
ファイル分けるとか?

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?