diff --git a/spec/example_app/app/dashboards/payment_dashboard.rb b/spec/example_app/app/dashboards/payment_dashboard.rb index 2460311de2..a7ede659be 100644 --- a/spec/example_app/app/dashboards/payment_dashboard.rb +++ b/spec/example_app/app/dashboards/payment_dashboard.rb @@ -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 diff --git a/spec/example_app/app/views/fields/receipt_link/_index.html.erb b/spec/example_app/app/views/fields/receipt_link/_index.html.erb new file mode 100644 index 0000000000..9f755667e8 --- /dev/null +++ b/spec/example_app/app/views/fields/receipt_link/_index.html.erb @@ -0,0 +1 @@ +<%= link_to field.filename, field.data %> diff --git a/spec/example_app/lib/administrate/field/receipt_link.rb b/spec/example_app/lib/administrate/field/receipt_link.rb new file mode 100644 index 0000000000..0756b259ce --- /dev/null +++ b/spec/example_app/lib/administrate/field/receipt_link.rb @@ -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