jbuilder.json テンプレートで常に次のようなコードを記述するのは面倒です。
json.extract! notification, :id, :user_id, :notice_type, :message, :resource_type, :resource_id, :unread, :created_at, :updated_at
だから私はこのようにコーディングしたいと思います。
json.extract_all! notification
次のコードのようにできることがわかりましたが、それでも少し長いです。
notification.attributes.each do |key, value|
json.set!(key, value)
end
もっと良い方法はありますか?