Adds index as: :calendar to ActiveAdmin — renders the resource list as a
month grid with one cell per day. The index block is yielded
(date, records_for_that_day).
Works with ActiveAdmin 3.5+ and 4.x.
# Gemfilegem"activeadmin_calendar"For Sprockets (AA 3):
/* app/assets/stylesheets/active_admin.scss */@import"activeadmin_calendar";Propshaft / Tailwind (AA 4) picks the bundled CSS up automatically.
One SQL query per visible month, rows bucketed in Ruby.
ActiveAdmin.registerPaymentdoconfig.paginate=falsefilter:card_type,as: :select,collection: Payment::CARD_TYPESindexas: :calendar,group_by: :paid_atdo |date,payments|
by_card=payments.group_by(&:card_type).transform_values{ |ps| ps.sum(&:amount)}uldoby_card.each{ |c,sum| li"#{c.upcase}: #{number_to_currency(sum)}"}total=by_card.values.sumli{strong"Total: #{number_to_currency(total)}"}unlesstotal.zero?endendendOne row appears in every day in its active range. Use a custom scope:
classBooking < ApplicationRecordscope:active_on,->(date){where("check_in <= ? AND check_out > ?",date,date)}endActiveAdmin.registerBookingdofilter:room_numberfilter:guest_name_cont,label: "Guest name contains"indexas: :calendar,group_by_scope: :active_ondo |date,bookings|
uldobookings.sort_by(&:room_number).eachdo |b|
first,last=b.check_in == date,b.check_out - 1.day == datemarker=first && last ? "•" : first ? "→" : last ? "←" : "·"li{text_node"#{marker} ##{b.room_number}#{b.guest_name}"}endendendendMay 18 → 21 booking shows on 18 (→), 19 (·), 20 (←).
| Option | Effect |
|---|---|
group_by: (Symbol) | Bucket by a date/datetime column. 1 SQL per month (prefetched). |
group_by_scope: (Symbol) | Call Model.scope(date) per cell — for ranges, joins, or any bucket logic that simple where(col = date) can't express. N SQL per month (one per visible day). |
URL params ?year=2026&month=5 drive the visible month. Today / Previous /
Next links are rendered automatically and preserve current filter params.
Ransack filters apply transparently — the gem buckets the already-scoped
collection. ?q[card_type_eq]=visa narrows what's shown in each cell.
| AA | Status |
|---|---|
| 4.0.0.beta22 | ✅ |
| 3.5 | ✅ |
MIT



