AuthLogic automatically loads errors into @base and populates those errors on a signin form
-
07-07-2019 - |
Question
(rdb:1) @account_session = AccountSession.new
# => <AccountSession: no credentials provided>
(rdb:1) @account_session.errors
# => <Authlogic::Session::Validation::Errors:0x213cc78 @errors={}, @base=#<AccountSession: no credentials provided>>
How do I prevent this? Also note, that credentials can't be provided in advance because that will populate the :new form with (incorrect) data. A new signin form should be blank.
Solution 2
I reproduced this on a vanilla Rails install that contains only AuthLogic. It revealed that the behavior described in this question is actually AuthLogic design behavior. I don't like this because calling #new on the model shouldn't result in errors if none really exist. And it's also funky if a form has UI elements that show error styling for @base errors. I'll address this on the gem's github issues.
OTHER TIPS
Are you validating your model in one of your methods/before-filters,etc?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow