A settings page for workspace members

Ruby · Rails · beginner · modification

Adds a settings page where a workspace member edits their own name, email and time zone. `config/routes.rb` adds a singular `resource :settings` with `edit` and `update`. The new `SettingsController` loads the signed-in member from `Current.member`, so there is no id in the URL, and on `update` saves the strong-params subset and redirects back with a notice, or re-renders the form with a 422. `settings/edit.html.erb` is the form (a `time_zone_select` for the zone). `settings_controller_test.rb` adds integration tests for the page and its save and validation paths.

Workspace app on Ruby 4.0 and Rails 8.1, SQLite in development and test (nothing here depends on the database engine), Minitest integration tests. Existing and unchanged (not shown): `ApplicationController` includes the `Authentication` concern, whose `before_action :require_authentication` sets `Current.member` to the signed-in `Member` or redirects to `new_session_path`; `Current` is an `ActiveSupport::CurrentAttributes` with `member` (and `account`, the member's account). Every controller action runs behind it unless it skips it. `Member` belongs to an `Account` and has `name` (string, at most 80 characters, required), `email` (normalized with `strip.downcase`, a valid address, unique across the app by validation and a unique index, used to sign in), `time_zone` (a name from `ActiveSupport::TimeZone.all`, default `UTC`) and `role`, a string enum `member` / `admin` / `owner` (default `member`). Admins and owners get the admin pages from `role`, read on every request. There is no email confirmation flow in this app: a member's email changes directly. Two members saving the same new email at the same instant is out of scope. `Admin::MembersController` (owners only) is where roles change. The test helper `sign_in_as(member)` signs the integration session in as that member. Forgery protection is on outside tests, and the layout renders `csrf_meta_tags`.

Requirements

Files touched

Review this PR

Ruby practice