I'm running Rails 3.2 and the latest version of Authlogic. When I run my app locally on my Mac, it works fine. When I try to run it on my production server (Ubuntu with Passenger/Apache), I get this:
You must establish a database connection before using acts_as_authentic
I'm not sure how to troubleshoot the problem. I posted this related question earlier today before I realized that the problem was broader than I thought.
Follow the open issue at https://github.com/binarylogic/authlogic/issues/318 and +1 so the fix gets merged soon :)
For anyone else who might have come to this page looking for an answer.
One reason could be that your haven't created your test database.
Just run:
I figured out the problem. Look at this snippet from Authlogic's
lib/authlogic/acts_as_authentic/base.rb
:If
column_names
throws an error,db_setup?
will return false. Look at this other function, also frombase.rb
:If
db_setup?
returns false, Authlogic will throw an exception, but not the same exception thrown bycolumn_names
.My problem was that
column_names
was throwing this exception:And the reason for THAT exception is that my user table is called
user
, notusers
, but Rails was not picking up on mypluralize_table_names
setting properly. Once I fixed mypluralize_table_names
problem (apparently the way this setting works has been changed in Rails 3.1), my Authlogic problem went away.So if you're having this problem, you might want to try this:
'authlogic', :path => '/path/to/authlogic'
)column_names
call todb_setup?
outside thebegin
/rescue
/end
clauseI've fixed this on my fork. Until Ben has time to merge the fix you can work around this using the fixed branch in your Gemfile;