Skip to content

Commit

Permalink
Receipt example
Browse files Browse the repository at this point in the history
  • Loading branch information
pablobm committed Sep 27, 2024
1 parent b579924 commit 2cb17a6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion spec/example_app/app/dashboards/payment_dashboard.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
require "administrate/field/receipt_link"
require "administrate/base_dashboard"

class PaymentDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::Number,
receipt: Field::ReceiptLink,
created_at: Field::DateTime,
updated_at: Field::DateTime,
order: Field::BelongsTo
}

COLLECTION_ATTRIBUTES = [
:id
:id,
:receipt
]

SHOW_PAGE_ATTRIBUTES = ATTRIBUTE_TYPES.keys
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<%= link_to field.filename, field.data %>
15 changes: 15 additions & 0 deletions spec/example_app/lib/administrate/field/receipt_link.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require "administrate/field/base"

module Administrate
module Field
class ReceiptLink < Base
def data
"/files/receipts/#{filename}"
end

def filename
"receipt-#{resource.id}.pdf"
end
end
end
end

0 comments on commit 2cb17a6

Please sign in to comment.