Rails 8 + ActiveAdmin: The Propshaft vs Sprockets Dilemma ๐Ÿ˜ตโ€๐Ÿ’ซ

ActiveAdmin traditionally requires Sprockets, but there are actually several alternatives and modern approaches. Let me break down your options:

ActiveAdmin Asset Pipeline Options:

Current Status (2025):

  • ActiveAdmin 3.x still primarily designed for Sprockets
  • It has SCSS files with imports, mixins, and variables that need preprocessing
  • The gem’s CSS compilation expects Sprockets’ asset compilation pipeline

Alternative Approaches:

1. Keep Sprockets (Current Choice)

Pros:

  • โœ… Fully supported, zero configuration issues
  • โœ… All ActiveAdmin features work out-of-the-box
  • โœ… Stable and well-tested

Cons:

  • โŒ Older, slower asset pipeline
  • โŒ More complex than Propshaft
  • โŒ Goes against Rails 8 defaults

2. Hybrid: Propshaft + Manual CSS for ActiveAdmin

We could try keeping Propshaft for our main app and handling ActiveAdmin CSS manually:

ActiveAdmin traditionally requires Sprockets, but the landscape is evolving. Here are your realistic options in 2025:

Current Situation:

ActiveAdmin 3.x: Requires Sprockets (stable)
ActiveAdmin 4.0 beta: Propshaft support is experimental/problematic
Rails 8 default: ๐Ÿ†• Propshaft (faster, simpler)

https://github.com/activeadmin/activeadmin/releases

Our Options:

Option 1: Stay with Sprockets โญ (Recommended for now)

Pros:

  • โœ… Zero configuration issues
  • โœ… All ActiveAdmin features work perfectly
  • โœ… Battle-tested and stable

Cons:

  • โŒ Slower than Propshaft
  • โŒ More complex asset pipeline
  • โŒ Goes against Rails 8 defaults

Option 2: ActiveAdmin Assets Gem (Simplest alternative)

The activeadmin_assets gem was mentioned as a simple solution! Let me add this option:

# Add to Gemfile
gem 'activeadmin_assets'

Pros:

  • โœ… Zero Node.js dependency
  • โœ… Works with Propshaft
  • โœ… Pre-compiled ActiveAdmin assets
  • โœ… Simple one-line installation

Cons:

  • โŒ Can’t customize ActiveAdmin styles
  • โŒ Community-maintained (not official)

Option 3: ActiveAdmin 4.0 Beta + Propshaft โš ๏ธ (Experimental)

Based on the GitHub discussions, this is possible but complex:

# Rails 8 setup with Propshaft + ActiveAdmin v4 beta
rails new myapp -a propshaft
bundle add activeadmin -v=4.0.0beta15
bundle add cssbundling-rails -v "1.4.1"
bundle add tailwindcss-ruby -v "~> 3.4.17"
yarn add tailwindcss@^3.4.17  # ActiveAdmin uses TailwindCSS v3
rails generate active_admin:install
rails css:install:tailwind
yarn add @activeadmin/activeadmin@4.0.0-beta15
npm pkg set scripts.build:css="tailwindcss -i ./app/assets/stylesheets/active_admin.css -o ./app/assets/builds/active_admin.css --minify -c tailwind-active_admin.config.js"
./bin/dev  # Instead of rails server

Pros:

  • โœ… Modern asset pipeline (Propshaft)
  • โœ… ActiveAdmin v4 features

Cons:

  • โŒ Complex setup with many steps
  • โŒ Requires Node.js/Yarn (defeats the purpose)
  • โŒ Beta software (unstable)
  • โŒ TailwindCSS v3/v4 compatibility issues

Option 4: ๐Ÿ”„ Alternative Admin Gems

If you want to avoid the ActiveAdmin complexity entirely:

RailsAdmin:

gem 'rails_admin'
  • โœ… No asset pipeline issues
  • โœ… Works with Propshaft out of the box
  • โŒ Less customizable than ActiveAdmin

Trestle:

gem 'trestle'
  • โœ… Modern Bootstrap-based admin
  • โœ… Better Rails 8 compatibility
  • โŒ Smaller community

Adminterface (Deprecated):

  • ๐Ÿšซ No longer maintained (as shown in search results)

๐Ÿ† My Recommendation:

For our production app: Stick with Sprockets + ActiveAdmin 3.x

Why?

  1. Stability – Battle-tested combination
  2. Zero configuration issues
  3. Full feature set available
  4. Easy maintenance

The performance difference between Propshaft and Sprockets won’t significantly impact your admin interface, which is typically used by a small number of internal users.

๐Ÿ”ฎ Future Outlook:

  • ActiveAdmin v4 will eventually have better Propshaft support
  • Rails community is working on solutions
  • Node.js dependency trend for complex CSS is becoming standard anyway

Bottom Line: Don’t let the asset pipeline take over the application preferences. Our current Sprockets setup is perfectly fine for an admin interface! ๐ŸŽฏ

The Reality Check:

We completely replaced Propshaft with Sprockets for the entire application.

Current State:

  • โŒ Propshaft: Completely removed
  • โœ… Sprockets: Handles ALL assets (main app + admin)
  • โœ… Importmaps: Still working (unaffected)
  • โœ… Hotwire/Turbo: Still working (unaffected)

๐Ÿ—๏ธ How ActiveAdmin Works:

ActiveAdmin is NOT a Rails Engine. It integrates directly into your app:

  1. Routes: ActiveAdmin.routes(self) adds /admin routes to your app
  2. Assets: ActiveAdmin’s CSS/JS becomes part of your asset pipeline
  3. Controllers: ActiveAdmin generates controllers in your app’s namespace

It’s tightly coupled to your application, not isolated.

๐Ÿคทโ€โ™‚๏ธ So What Are Our Real Options?

Option 1: Accept Current Setup

What we have:

  • Modern Rails 8 with Importmaps + Hotwire โœ…
  • Sprockets instead of Propshaft โŒ (but works fine)
  • Full-featured admin interface โœ…

Option 2: Use activeadmin_assets Gem

# Replace current ActiveAdmin setup
gem 'activeadmin_assets'  # Pre-compiled assets
gem 'propshaft'           # Back to Rails 8 default
  • โœ… Get Propshaft back
  • โœ… Keep Rails 8 defaults
  • โŒ Can’t customize admin styles

Option 3: Build Custom Admin

Keep your Rails 8 purity but build admin from scratch:

  • โœ… Pure Rails 8
  • โŒ Weeks of development time

๐Ÿ” What activeadmin_assets Actually Does:

The activeadmin_assets gem doesn’t replace ActiveAdmin – it provides pre-compiled static assets for ActiveAdmin to work with Propshaft.

But here’s the critical issue for you:

๐Ÿšจ activeadmin_assets = NO Customization

If you use activeadmin_assets, you get:

  • โœ… ActiveAdmin functionality
  • โœ… Propshaft compatibility
  • โŒ ZERO ability to customize styles/interface

The assets are pre-compiled and frozen – you can’t modify colors, layouts, or styling.

Since We Want Customization:

We’re actually in the BEST setup possible right now!

Our Current Setup Gives You:

  • โœ… Full ActiveAdmin customization (styles, layouts, themes)
  • โœ… Modern Rails 8 (Importmaps, Hotwire, Turbo)
  • โœ… All ActiveAdmin features (filters, actions, forms)
  • โŒ Sprockets instead of Propshaft (minor trade-off)

Customization Examples We Can Do:

  • Custom CSS themes and colors
  • Layout modifications
  • Custom JavaScript behaviors
  • Brand styling and logos
  • Advanced form customizations

๐ŸŽฏ Reality Check:

There’s no solution that gives us:

  1. Full ActiveAdmin customization AND
  2. Propshaft AND
  3. Zero complexity

We have to pick 2 out of 3.

๐Ÿ’ก My Honest Last Decision:

Keep our current setup! We’re already using:

  • Modern Rails 8 patterns (95% of your codebase)
  • Importmaps and Hotwire (exactly as intended)
  • Sprockets only affects asset serving (invisible to users)

The Propshaft vs Sprockets difference won’t affect your product’s success, but losing admin customization will limit our UX.


๐Ÿ“ฆ Sprockets vs ๐Ÿงต Propshaft in Ruby on Rails 7/8 โ€“ What’s the Difference?

When working with asset pipelines in Ruby on Rails 7 and 8, you might encounter Sprockets and Propshaftโ€”two asset handling libraries. While both aim to serve static assets like JavaScript, CSS, images, and fonts, they do so in different ways.

This post will walk you through what each does, how they differ, and when you might want to use one over the other.


๐Ÿ“ฆ What is Sprockets?

Sprockets is the original Rails asset pipeline system, introduced way back in Rails 3.1. It allows developers to:

  • Concatenate and minify JavaScript and CSS
  • Preprocess assets using things like SCSS, CoffeeScript, ERB, etc.
  • Fingerprint assets for cache busting
  • Compile assets at deploy time

It works well for traditional Rails applications where the frontend and backend are tightly coupled.

Pros:

  • Mature and stable
  • Rich preprocessing pipeline (SCSS, CoffeeScript, ERB, etc.)
  • Supports advanced directives like //= require_tree .

Cons:

  • Complex internal logic
  • Slower compilation times
  • Relies on a manifest file that can get messy
  • Tightly coupled with older Rails asset practices

๐Ÿงต What is Propshaft?

Propshaft is the newer asset pipeline introduced by the Rails team as an alternative to Sprockets. It focuses on simplicity and modern best practices. Propshaft was added as an optional asset pipeline starting in Rails 7 and is included by default in some new apps.

Design Philosophy:
Propshaft aims to work like a static file server with fingerprinting and logical path mapping, rather than a full asset compiler.

Key Features:

  • Uses logical paths (e.g., /assets/application.css)
  • No preprocessing pipeline by default (but supports it via extensions like Tailwind or Sass)
  • Supports digesting (fingerprinting) of assets
  • Leaner and faster than Sprockets
  • Easier to integrate with modern JavaScript bundlers (like importmaps, esbuild, or webpack)

Pros:

  • Lightweight and fast
  • Easier to debug
  • Works great with importmaps and Hotwire
  • Modern, forward-looking approach

Cons:

  • No advanced preprocessing by default
  • Limited plugin ecosystem (still maturing)
  • Doesn’t support old Sprockets directives

๐Ÿ” Key Differences at a Glance

FeatureSprocketsPropshaft
Introduced InRails 3.1Rails 7
Default in RailsRails 6 and earlierOptional from Rails 7+
Preprocessing SupportYes (SCSS, ERB, CoffeeScript, etc.)No (only raw assets by default)
SpeedSlowerFaster
Configuration ComplexityHigherMinimal
Plugin EcosystemLarge and matureNew and growing
Use With Importmaps/HotwireCan work, but heavierIdeal
DebuggingHarder due to complexityEasier

๐Ÿงฐ When Should You Use Sprockets?

Choose Sprockets if:

  • You are upgrading a legacy Rails app
  • Your project already relies on Sprockets
  • You use heavy asset preprocessing
  • You need compatibility with gems that depend on Sprockets

โšก When Should You Use Propshaft?

Choose Propshaft if:

  • You are starting a new Rails 7/8 project
  • You use Importmaps or Hotwire/Turbo
  • You prefer faster and simpler asset handling
  • You don’t need complex preprocessing

Propshaft pairs particularly well with modern frontend workflows like Tailwind CSS (via build tools) or StimulusJS (with importmaps).

๐Ÿ› ๏ธ Switching from Sprockets to Propshaft

If you’re migrating, here are basic steps:

  1. Remove sprockets-rails gem from your Gemfile: # Gemfile # gem "sprockets-rails"
  2. Add propshaft: gem "propshaft"
  3. Update config/application.rb: config.assets.resolver = Propshaft::Resolver.new( paths: [Rails.root.join("app/assets")] )
  4. Remove app/assets/config/manifest.js (used by Sprockets)
  5. Move all assets to the correct logical paths under app/assets
  6. Use digested URLs as needed (asset_path("application.css") etc.)

๐Ÿงช Real Example in Rails 8

Hereโ€™s how your application.html.erb might look using Propshaft:

<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %>
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %>

And your app/assets/builds/application.css could be compiled via Tailwind or SCSS using a toolchain.


๐Ÿง  Final Thoughts

Sprockets has served Rails well for over a decade, but Propshaft is the new lightweight future. If you’re starting fresh, Propshaft is a strong choice, especially when used alongside Hotwire, Importmaps, or modern JS bundlers.

However, don’t feel pressured to switch if your current Sprockets setup works fineโ€”Rails continues to support both.


โœจ TL;DR

  • Sprockets = older, feature-rich, best for legacy apps
  • Propshaft = newer, minimal, better for modern workflows

Choose based on your app’s needs and complexity. Cheers! ๐Ÿš€

The Evolution of Asset ๐Ÿ“‘ Management in Web and Ruby on Rails

Understanding Middleware in Rails

When a client request comes into a Rails application, it doesn’t always go directly to the MVC (Model-View-Controller) layer. Instead, it might first pass through middleware, which handles tasks such as authentication, logging, and static asset management.

Rails uses middleware like ActionDispatch::Static to efficiently serve static assets before they even reach the main application.

ActionDispatch::Static Documentation

“This middleware serves static files from disk, if available. If no file is found, it hands off to the main app.”

Where Are Static Files Stored?

Rails stores static assets in the public/ directory, and ActionDispatch::Static ensures these are served efficiently without hitting the Rails stack.

Core Components of Ruby on Rails – A reminder

To understand asset management evolution, let’s quickly revisit Rails’ core components:

  • ActiveRecord: Object-relational mapping (ORM) system for database interactions.
  • Action Pack: Handles the controller and view layers.
  • Active Support: A collection of utility classes and standard library extensions.
  • Action Mailer: A framework for designing email services.

The Role of Browsers in Asset Management

Web browsers cache static assets to improve performance. The caching strategy varies based on asset types:

  • Images: Rarely change, so they are aggressively cached.
  • JavaScript and CSS files: Frequently updated, requiring cache-busting mechanisms.

The Era of Sprockets

Historically, Rails used Sprockets as its default asset pipeline. Sprockets provided:

  • Conversion of CoffeeScript to JavaScript and SCSS to CSS.
  • Minification and bundling of assets into fewer files.
  • Digest-based caching to ensure updated assets were fetched when changed.

The Rise of JavaScript & The Shift Towards Webpack

The release of ES6 (2015-2016) was a turning point for JavaScript, fueling the rise of Single Page Applications (SPAs). This marked a shift from traditional asset management:

  • Sprockets was effective but became complex and difficult to configure for modern JS frameworks.
  • Projects started including package.json at the root, indicating JavaScript dependency management.
  • Webpack emerged as the go-to tool for handling JavaScript, offering features like tree-shaking, hot module replacement, and modern JavaScript syntax support.

The Landscape in 2024: A More Simplified Approach

Recent advancements in web technology have drastically simplified asset management:

  1. ES6 Native Support in All Major Browsers
    • No need for transpilation of modern JavaScript.
  2. CSS Advancements
    • Features like variables and nesting eliminate the need for preprocessors like SASS.
  3. HTTP/2 and Multiplexing
    • Enables parallel loading of multiple assets over a single connection, reducing dependency on bundling strategies.

Enter Propshaft: The Modern Asset Pipeline

Propshaft is the new asset management solution introduced in Rails, replacing Sprockets for simpler and faster asset handling. Key benefits include:

  • Digest-based file stamping for effective cache busting.
  • Direct and predictable mapping of assets without complex processing.
  • Better integration with HTTP/2 for efficient asset delivery.

Rails 8 Precompile Uses Propshaft

What is Precompile? A Reminder

Precompilation hashes all file names and places them in the public/ folder, making them accessible to the public.

Propshaft improves upon this by creating a manifest file that maps the original filename as a key and the hashed filename as a value. This significantly enhances the developer experience in Rails.

Propshaft ultimately moves asset management in Rails to the next level, making it more efficient and streamlined.

The Future of Asset Management in Rails

With advancements like native ES6 support and CSS improvements, Rails continues evolving to embrace simpler, more efficient asset management strategies. Propshaft, combined with modern browser capabilities, makes asset handling seamless and more performance-oriented.

As the web progresses, we can expect further simplifications in asset pipelines, making Rails applications faster and easier to maintain.

Stay tuned for more innovations in the Rails ecosystem!

Happy Rails Coding! ๐Ÿš€