Add toggle to enable/disable auto-rule creation prompts on the Rules page
Previously, the only way to re-enable auto-rule prompts after dismissing them was to wait 24 hours or edit the DB directly. This adds an "Automation" toggle at the top of the Rules page so users can manage this setting at any time.
Changes
UsersController– Permittedrule_prompts_disabledthroughuser_paramsand added a"rules"redirect case inhandle_redirectso saving from the Rules page returns the user thereRulesController– Set@user = Current.userin theindexaction to expose the user model for the toggle form- Rules index view – Added an "Automation"
settings_sectionat the top of the page with an auto-submittingDS::Togglebound directly torule_prompts_disabled(with invertedchecked_value/unchecked_valueso the toggle is visually ON when prompts are enabled) - Locales (
rules/en.yml) – Addedautomation_title,automation_subtitle,rule_prompts_label,rule_prompts_hintkeys underrules.index
Original prompt
This section details on the original issue you should resolve
<issue_title>Add user-friendly toggle for auto-rule creation prompts</issue_title>
<issue_description>## ProblemCurrently, users can only disable the auto-rule creation prompt by clicking "Don't show this again" when the prompt appears. To re-enable it, they have to either:
- Wait 24 hours for the prompt to reappear
- Edit the database directly
There is no user-friendly way to toggle this setting from the UI.
Solution
Add a toggle to the Preferences settings page that allows users to enable/disable auto-suggestion of rules when categorizing transactions.
Changes needed
1. app/models/user.rb
Add virtual attribute for the toggle:
# Virtual attribute for UI: inverts rule_prompts_disabled for a more intuitive toggle def rule_prompts_enabled !rule_prompts_disabled end def rule_prompts_enabled=(value) self.rule_prompts_disabled = !value end2. app/views/settings/preferences/show.html.erb
Add new Automation section with toggle:
<%= settings_section title: t(".automation_title"), subtitle: t(".automation_subtitle") do %> <div> <%= styled_form_with model: @user, class: "space-y-4", data: { controller: "auto-submit-form" } do |form| %> <%= form.hidden_field :redirect_to, value: "preferences" %> <%= form.switch :rule_prompts_disabled, label: t(".rule_prompts_label"), hint: t(".rule_prompts_hint"), checked: !@user.rule_prompts_disabled, data: { auto_submit_form_target: "auto" } %> <% end %> </div> <% end %>3. config/locales/views/settings/en.yml
Add locale strings:
automation_title: Automation automation_subtitle: Control automatic behavior rule_prompts_label: Auto-suggest rules when categorizing rule_prompts_hint: Show a prompt to create a rule when you assign a category to a transactionAcceptance Criteria
- Users can toggle auto-rule prompts on/off from Settings → Preferences
- Toggle label clearly indicates what it does
- Changes save automatically (auto-submit)
- Works for both enabling and disabling the feature
</issue_description>Comments on the Issue (you are @copilot in this section)
- Fixes we-promise/sure#1280
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.
Summary by CodeRabbit
-
New Features
- Added Automation settings section to user preferences
- Added rule prompts toggle with automatic saving
-
Tests
- Added test coverage for rule prompts functionality