Closed ghost closed 7 years ago
Using authlogic with STI User models
I’m not sure, but I dont think it would be difficult to support. What are the specific errors?
by Ben Johnson
Using authlogic with STI User models
I’m using authlogic with STI right now and everything seems to work fine under development, but when I run it in production mode and attempt to update a model, this is what I get:
NoMethodError (undefined method `=’ for #<Patient:0xb34032c>):
authlogic (2.1.1) [v] lib/authlogic/acts_as_authentic/password.rb:229:in `send’
authlogic (2.1.1) [v] lib/authlogic/acts_as_authentic/password.rb:229:in `password=’
Here’s the current setup for the models:
class User < ActiveRecord::Base
acts_as_authentic
end
class Patient < User;end
class Doctor < User;end
I looked at the password method, but I’m not sure what is happening or what to look for, is authlogic actually passing the whole model to the password method. Any help would be much appreciated.
Thanks!
Vann
by Vann
Using authlogic with STI User models
It looks like:
Patient.crypted_password_field
Is returning nil. What does Patient.column_names return for you?
by Ben Johnson
Using authlogic with STI User models
Here’s what it returns:
Patient.column_names Patient Columns (3.2ms) SHOW FIELDS FROM
users
=> ["id", "login", "name", "email", "crypted_password", "salt", "created_at", "updated_at", "remember_token", "remember_token_expires_at", "first_name", "last_name", "ssn", "address", "city", "state", "zip", "drivers_license", "home_phone", "cell_phone", "fax", "employer", "insurance_co", "insurance_type", "insurance_id", "allergies", "medications", "operations", "chronic_conditions", "family_history", "immunizations", "visits_count", "appointments_count", "login_count", "getting_started", "type"]
by Vann
I was about to use STI user models too, but don't really looking for trouble right now. What's the status on this? 8)
@binarylogic what version of rails are you using? I am using authlogic with STI and it works beautifully on rails 2.3.2.
Actually there is one thing that I am having trouble with and that is the password reset feature when using STI. It wants the param user. However my params for :user are nil. If I change to the appropriate STI class name it works fine but I have multiple STI sub class names. Any idea how I would fix that?
Thanks to rsl, he showed me http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002334. In the form_for rather than using @user use @user.becomes(User) and it works beautifully again. Thanks again rsl.
I too am using an app that uses authlogic and STI on User and it all works fine for me. I'm using authlogic 2.1.6 and rails 2.3.10
Closing after six years with no activity. If this is still a problem in the latest version (currently 3.5.0), please let us know.
Using authlogic with models that extend the User class (using Single Table Inheritance) seems to break things since you end up with nil objects for @current_user in your controllers
@@@ ruby class User < ActiveRecord::Base acts_as_authentic end class NormalUser < User;end class SpecialUser < User;end @@@
Is it possible to use authlogic with STI?
original LH ticket
This ticket has 0 attachment(s).