Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rails generate settings:admin UI #259

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

yshmarov
Copy link

@yshmarov yshmarov commented Jan 11, 2025

#258

rails generate settings:admin generates views.

moved from Readme to generator

☑️ fixed validator
☑️ generic UI & strong params based on attributes defined in Settings.rb
☑️ generate example tests
☑️ hash saves correctly

with applied
<link rel="stylesheet" href="https://cdn.simplecss.org/simple.min.css">

Screenshot 2025-01-11 at 23 55 44

without any CSS

Screenshot 2025-01-11 at 23 56 08

handle errors
Screenshot 2025-01-12 at 00 17 10

handle select field

  ENABLED_CURRENCIES = %w[USD EUR PLN]

  scope :payments do
    field :currency, default: "USD", type: :string, validates: { presence: true, inclusion: { in: ENABLED_CURRENCIES } }, option_values: ENABLED_CURRENCIES
  end

=>

Screenshot 2025-01-19 at 13 41 40

The generated interface:
- Groups settings by scope
- Handles all setting types (string, boolean, array, hash)
- Shows validation errors
- Includes basic styling
- Supports help text from field definitions
@yshmarov yshmarov marked this pull request as ready for review January 11, 2025 23:18
@yshmarov yshmarov changed the title rails generate settings:admin rails generate settings:admin UI Jan 11, 2025
otherwise it saved as
```
--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
send_all: true
logging: true
sender_email: EDITED@bar.com
```
@yshmarov
Copy link
Author

as a next step, instead of devs importing the views & controllers, we can

    mount Settings::Engine, at: "/admin/settings"

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.

1 participant