mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-31 03:09:06 -04:00
Declare read-only resources and the owner relationship once each, make the resource hook helpers private, simplify token auth, and cache the generated API docs for an hour.
20 lines
483 B
Ruby
20 lines
483 B
Ruby
# frozen_string_literal: true
|
|
|
|
class PhotoResource < ApplicationResource
|
|
self.model = Photo
|
|
read_only
|
|
|
|
attribute :thumbnail_url, :string
|
|
attribute :fullsize_url, :string
|
|
attribute :license_name, :string
|
|
attribute :link_url, :string
|
|
attribute :title, :string
|
|
|
|
filter :crop_id, :integer do
|
|
eq { |scope, ids| scope.where(id: PhotoAssociation.where(crop_id: ids).select(:photo_id)) }
|
|
end
|
|
|
|
owned
|
|
%w(Planting Garden Harvest).each { |type| photographed type }
|
|
end
|