-
Hello! I'm having problems trying to use a custom model with I have a custom class User < ApplicationRecord
include Rodauth::Rails.model
enum :status, unverified: 1, verified: 2, closed: 3
end Then I configured class RodauthMain < Rodauth::Rails::Auth
configure do
...
accounts_table :users
rails_account_model User
login_column :name
login_uses_email? false
email_to do
account[:email]
end
end My only existing require "rodauth/model"
class RodauthApp < Rodauth::Rails::App
configure RodauthMain
route do |r|
rodauth.load_memory
r.on "auth" do
r.rodauth
end
end
end The problem is whenever I try to call a protected endpoint in one of my API controllers I get this error:
Does anybody have an idea what could cause this error? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, thanks for posting the relevant code. I believe there is a circular dependency issue going on here:
Ideally, you should have received an error that the main configuration ( Changing rails_account_model { User } Also, note that setting |
Beta Was this translation helpful? Give feedback.
Hi, thanks for posting the relevant code. I believe there is a circular dependency issue going on here:
RodauthApp
, it starts loadingrodauth_app.rb
rodauth_app.rb
referencesRodauthMain
, it starts loadingrodauth_main.rb
(at that point the Rodauth configuration hasn't yet been registered into the app)rodauth_main.rb
references theUser
model, it starts loadinguser.rb
user.rb
includes the model mixin, the mixin tries to retrieve the Rodauth configuration in order to read table & column namesIdeally, you should have received an error that the main configuration (
nil
)…