Skip to content

Repository files navigation

activeadmin_calendar

CICoverageRuby

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.

ActiveAdmin 4

Payments calendar on AA 4

ActiveAdmin 3

Payments calendar on AA 3.5

Install

# 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.

Usage

Single-date events — group_by:

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?endendend

Range / fan-out events — group_by_scope:

One row appears in every day in its active range. Use a custom scope:

ActiveAdmin 4

Bookings calendar — fan-out on AA 4

ActiveAdmin 3

Bookings calendar — fan-out on AA 3.5

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}"}endendendend

May 18 → 21 booking shows on 18 (), 19 (·), 20 ().

Options

OptionEffect
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.

Compatibility

AAStatus
4.0.0.beta22
3.5

License

MIT

About

Calendar index style for ActiveAdmin (AA 3.5 + 4 compatible)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages