User Profile โ
Add a profile / account-settings page where users edit personal fields and access Rodauth security features (change password, 2FA, etc.) in one place.
Goal โ
A /profile URL that shows the user's personal fields plus a "Security" section linking to Rodauth-managed features.
๐จ Critical โ
- Profile association is always
:profileregardless of the model class โcurrent_user.profile,build_profile,params.require(:profile)always work. - Profile needs
pu:profile:connto be visible โ without it, no/profileroute, noprofile_urlhelper. - Every user needs a profile row. Add an
after_create :create_profile!callback to the user model. Without it,current_user.profileis nil.
The show page renders the user's fields, then the Security Settings block with Rodauth-backed actions:

Editing produces a regular Plutonium form โ same form generator the rest of your resources use:

Quick path โ
rails g pu:profile:setup date_of_birth:date bio:text \
--dest=competition \
--portal=competition_portalpu:profile:setup is a meta-generator โ runs pu:profile:install + pu:profile:conn in one shot.
Step-by-step โ
1. Install โ
rails generate pu:profile:install bio:text avatar:attachment 'timezone:string?' \
--dest=customer| Option | Default | Description |
|---|---|---|
--dest=DEST | (prompts) | Target package or main_app |
--user-model=NAME | User | Rodauth user model |
Custom resource name (first positional argument):
rails g pu:profile:install AccountSettings bio:text --dest=main_appBy default the model is {UserModel}Profile (UserProfile, StaffUserProfile, etc.).
2. Migrate โ
rails db:prepare3. Connect to a portal โ
rails g pu:profile:conn --dest=customer_portalThis registers the profile as a singular resource โ exposes /profile (no :id) and the profile_url helper.
4. Add the auto-create callback โ
# app/models/user.rb (modified by pu:profile:install)
class User < ApplicationRecord
has_one :profile, class_name: "UserProfile", dependent: :destroy
after_create :create_profile!
private
def create_profile! = create_profile
endFor existing users at migration time:
rails runner "User.find_each(&:create_profile)"What you get โ
The generated definition injects a custom ShowPage that renders SecuritySection โ dynamically lists Rodauth security links based on which features are enabled:
| Feature enabled | Link rendered |
|---|---|
change_password | Change Password |
change_login | Change Email |
otp | Two-Factor Authentication |
recovery_codes | Recovery Codes |
webauthn | Security Keys |
active_sessions | Active Sessions |
close_account | Close Account |
If a feature isn't enabled, its link doesn't render โ no configuration needed.
Linking to the profile โ
link_to("Profile", profile_url) if respond_to?(:profile_url)The respond_to? guard is defensive โ only portals that ran pu:profile:conn have the helper.
Customizing the definition โ
The generated profile is a normal Plutonium definition. Customize like any other:
class UserProfileDefinition < Plutonium::Resource::Definition
field :bio, as: :markdown
input :avatar, as: :uppy
field :timezone, as: :select, choices: ActiveSupport::TimeZone.all.map(&:name)
metadata :created_at, :updated_at
class ShowPage < ShowPage
private
def render_after_content
render Plutonium::Profile::SecuritySection.new
end
end
endSee Reference โบ Resource โบ Definition for the full definition surface.
Multiple account types โ
If your app has both User and StaffUser accounts, run pu:profile:install once per:
rails g pu:profile:install --user-model=User --dest=main_app
rails g pu:profile:install --user-model=StaffUser --dest=main_appEach gets its own *Profile model with :profile association on the respective user. Connect each to the appropriate portal:
rails g pu:profile:conn UserProfile --dest=customer_portal
rails g pu:profile:conn StaffUserProfile --dest=admin_portalCommon issues โ
current_user.profileis nil โ every user needs a profile row. Addafter_create :create_profile!to the user model.profile_urlis undefined โ the profile isn't connected to this portal. Runpu:profile:conn --dest=<portal>.SecuritySectionshows nothing โ none of the relevant Rodauth features are enabled. Enablechange_password,otp, etc. on the Rodauth plugin.
Related โ
- Reference โบ Auth โบ Profile โ full surface
- Reference โบ Auth โบ Accounts โ Rodauth feature flags that gate SecuritySection
- Authentication โ the underlying auth setup
