diff --git a/spec/dummy/app/avo/resources/attachment_resource.rb b/spec/dummy/app/avo/resources/attachment_resource.rb new file mode 100644 index 0000000000..4b36388ea6 --- /dev/null +++ b/spec/dummy/app/avo/resources/attachment_resource.rb @@ -0,0 +1,9 @@ +class AttachmentResource < Avo::BaseResource + self.title = :filename + self.model_class = "ActiveStorage::Attachment" + + field :id, as: :id + field :filename, as: :text + field :service_url, as: :external_image, name: "Image" + field :created_at, as: :date_time +end diff --git a/spec/dummy/app/avo/resources/post_resource.rb b/spec/dummy/app/avo/resources/post_resource.rb index 1437d57dd3..4f7d905cfa 100644 --- a/spec/dummy/app/avo/resources/post_resource.rb +++ b/spec/dummy/app/avo/resources/post_resource.rb @@ -42,6 +42,8 @@ class PostResource < Avo::BaseResource extract_excerpt model.body end + field :cover_photo_attachment, as: :has_one + field :is_featured, as: :boolean, visible: ->(resource:) { context[:user].is_admin? } field :is_published, as: :boolean do |model| model.published_at.present? diff --git a/spec/dummy/app/avo/resources/project_resource.rb b/spec/dummy/app/avo/resources/project_resource.rb index 50e041832e..e95695e947 100644 --- a/spec/dummy/app/avo/resources/project_resource.rb +++ b/spec/dummy/app/avo/resources/project_resource.rb @@ -35,6 +35,8 @@ class ProjectResource < Avo::BaseResource field :comments, as: :has_many, searchable: true field :reviews, as: :has_many + field :files_attachments, as: :has_many + action ExportCsv # filter PeopleFilter diff --git a/spec/dummy/app/controllers/avo/attachments_controller.rb b/spec/dummy/app/controllers/avo/attachments_controller.rb new file mode 100644 index 0000000000..bdd1bb2812 --- /dev/null +++ b/spec/dummy/app/controllers/avo/attachments_controller.rb @@ -0,0 +1,4 @@ +# This controller has been generated to enable Rails' resource routes. +# More information on https://docs.avohq.io/2.0/controllers.html +class Avo::AttachmentsController < Avo::ResourcesController +end