Repository navigation
Fix model generation, decimal inputs and Badge variants; use ruby_ui 1.6 from RubyGems - #2
Merged
Merged
Conversation
…from RubyGems - Railtie no longer requires generator classes in its `generators` block. Rails runs those blocks before `Rails::Generators.configure!`, so loading Rails' ModelGenerator there froze its `:orm` hook as `false` and `rails g ruby_ui_scaffold` (and plain `rails g model`) skipped the model and migration. The entry generator now requires its sub-generators, since Rails' hook lookup only loads the first matching candidate file. - Stringify decimal input values: Phlex 2 rejects BigDecimal attributes, which crashed the edit form. - Pass Badge variants as symbols; RubyUI::Badge::COLORS is symbol-keyed, so string variants rendered without colors. - Installer adds `gem "ruby_ui", "~> 1.6"` from RubyGems instead of the GitHub main branch. Verified end-to-end against ruby_ui 1.6.0. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Compatibility check against ruby_ui 1.6.0 (latest). Every component and kwarg the templates use exists in 1.6.0, but an end-to-end run in a fresh Rails 8.1 app found three bugs in this gem. None of them is caused by ruby_ui 1.6.
Fixed
rails g ruby_ui_scaffoldgenerated no model or migration. Having the gem in the Gemfile also broke plainrails g model. The Railtie'sgeneratorsblock required generator classes, and Rails runs those blocks beforeRails::Generators.configure!. That loadedModelGeneratorearly and froze its:ormhook asfalse. The Railtie now only sets option defaults, and the classes load lazily. Because Rails' hook lookup requires only the first existing candidate file, the entry generator now requires its sub-generators. Without that, the views hook reportsruby_ui_scaffold [not found].decimalcolumns withPhlex::ArgumentError (Invalid attribute value for value: 0.58206e3). Phlex 2 rejectsBigDecimalattribute values, so the value is now&.to_s, which renders as"582.06".Badgehad no colors. Variants were passed as strings, butRubyUI::Badge::COLORSis symbol-keyed, so they are now:success/:outline.Changed
gem "ruby_ui", "~> 1.6", require: falsefrom RubyGems instead of the GitHubmainbranch. Existing GitHub entries are still detected and left alone.Test plan
rake test: 122 runs, 0 failurestest/railtie_test.rbboots a minimal app in a subprocess through the realload_generatorspath. It asserts the:ormdefault and resolves the sub-generators the same way the hooks do. Confirmed it fails both without the Railtie fix and without the sub-generator requires.ruby_uiin the Gemfile:--datatablecovering string, text, decimal, float, integer, boolean, date, datetime and references.seedworked.--skip-modelre-runs worked.🤖 Generated with Claude Code