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

Change the model name #56

Closed
resgar opened this issue Aug 3, 2021 · 1 comment
Closed

Change the model name #56

resgar opened this issue Aug 3, 2021 · 1 comment

Comments

@resgar
Copy link

resgar commented Aug 3, 2021

Is there a way to rename the model to User instead of Account?
I'm building a banking app that has a table called accounts to store users' bank account details. I don't want to change the table name to something else, because it can be misleading to developers.

@janko
Copy link
Owner

janko commented Aug 3, 2021

Yes, you can rename the tables and then update the Rodauth configuration to reference new table names:

configure do
  accounts_table :users
  reset_password_table :user_password_reset_keys
  remember_table :user_remember_keys
  # ...
end

To do it for all Rodauth tables, you can use this code:

configure do
  methods.grep(/_table$/) do |table_method|
    public_send(table_method) { super().to_s.sub('account', 'user').to_sym }
  end
end

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

No branches or pull requests

2 participants