Skip to content

Require 'date' so attribute serialization works without Rails - #981

Merged
joeldrapper merged 1 commit into
yippee-fun:mainfrom
mikolajczu:fix/require-date
May 21, 2026
Merged

Require 'date' so attribute serialization works without Rails#981
joeldrapper merged 1 commit into
yippee-fun:mainfrom
mikolajczu:fix/require-date

Conversation

@mikolajczu

@mikolajczu mikolajczu commented May 21, 2026

Copy link
Copy Markdown
Contributor

Fixes #974

If you use Phlex outside of Rails, rendering attributes can blow up with NameError: uninitialized constant Phlex::SGML::Attributes::Date. The attribute serializer has a case/when Date branch, but Date lives in the stdlib and isn't loaded automatically. Rails apps don't hit this because ActiveSupport pulls in date early.

I added require "date" to lib/phlex.rb, next to the existing require "set". Same convention: Set is also used inside attributes.rb and required at the top level.

The regression test in quickdraw/load.test.rb runs in a subprocess on purpose. Nokogiri is in the test bundle and ends up loading date, so checking inline would always pass and wouldn't actually catch this bug coming back.

@mikolajczu
mikolajczu marked this pull request as ready for review May 21, 2026 00:39
@joeldrapper
joeldrapper merged commit ade4222 into yippee-fun:main May 21, 2026
0 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uninitialized constant Phlex::SGML::Attributes::Date` with Ruby 3.4 (standalone, no Rails)

2 participants