Add toggle to enable/disable auto-rule creation prompts on the Rules page

Closed
CO
2mo ago
+39-1

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 – Permitted rule_prompts_disabled through user_params and added a "rules" redirect case in handle_redirect so saving from the Rules page returns the user there
  • RulesController – Set @user = Current.user in the index action to expose the user model for the toggle form
  • Rules index view – Added an "Automation" settings_section at the top of the page with an auto-submitting DS::Toggle bound directly to rule_prompts_disabled (with inverted checked_value/unchecked_value so the toggle is visually ON when prompts are enabled)
  • Locales (rules/en.yml) – Added automation_title, automation_subtitle, rule_prompts_label, rule_prompts_hint keys under rules.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>## Problem

Currently, 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
end

2. 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 transaction

Acceptance 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)


📱 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