Skip to content
This repository

Fix broken migrations caused by #290 #323

merged 2 commits into from over 1 year ago

8 participants

James McCarthy Marc O'Morain ctilley83 Ellis Berner James Herdman Tim Olshansky Rico Sta. Cruz Ben Johnson
James McCarthy

Hi Ben,

I've fixed #318 and #322 which were caused by #290 raising an exception on !db_setup? which meant migrations were never run. I've partially restored your original code to check whether the table exists.

It would be good to get this in as it's hindering people setting up new projects with Authlogic.


added some commits July 12, 2012
Marc O'Morain

Thanks for fixing this James. It would be great to get this merged as soon as possible, we had to jump though some hoops to work around it.


Cloning the fixed branch does not work. Why can't you merge the fix into master. It seems like it's taking an act of God to get this fixed.

James McCarthy
James McCarthy

Can you tell me what the typo is and I'll fix it.

Ellis Berner


James Herdman


Tim Olshansky


Ben Johnson yourewelcome merged commit beaabc5 into from October 23, 2012
Ben Johnson yourewelcome closed this October 23, 2012
Rico Sta. Cruz

This fix has a small caveat. If you have User.create in your seeder (db/seeds.rb), this won't be doable anymore:

$ rake db:drop
$ rake db:setup

It gets you this error:

undefined method 'password=' for #<User:....>

This is because acts_as_authentic has return unless table_exists? which stops it from creating the password= method.

Rico Sta. Cruz

...actually, forget that: that bug has existed since 2 years ago.#88

James McCarthy

@rstacruz That explains something I've never got round to investigating. It's only a problem if you run your seeds in the same session as your migrations right? e.g.

$ rake db:migrate db:seed
Rico Sta. Cruz

@james2m Yes, which Rails does by default with:

$ rake db:setup

...which is simply an alias for db:create db:schema:load db:seed.

James McCarthy james2m deleted the branch December 03, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 2 unique commits by 1 author.

Jul 12, 2012
James McCarthy Ignored .rvmrc files. 8856d88
James McCarthy Fixes #318 and fixes #322 broken migrations caused by #290.
Signed-off-by: James McCarthy <>
This page is out of date. Refresh to see the latest.
1  .gitignore
@@ -7,3 +7,4 @@ coverage/*
7 7
8 8
9 9
5  lib/authlogic/acts_as_authentic/base.rb
@@ -28,7 +28,10 @@ module Config
28 28
         # See the various sub modules for the configuration they provide.
29 29
         def acts_as_authentic(unsupported_options = nil, &block)
30 30
           # Stop all configuration if the DB is not set up
-          raise"You must establish a database connection before using acts_as_authentic") if !db_setup?
+          return unless table_exists?
+          # Raise an error if you've loaded the model without establishing a valid database connection.
+          raise"You must establish a database connection before using acts_as_authentic") unless connection.present?
32 35
33 36
           raise"You are using the old v1.X.X configuration method for Authlogic. Instead of " +
34 37
             "passing a hash of configuration options to acts_as_authentic, pass a block: acts_as_authentic { |c| c.my_option = my_value }") if !unsupported_options.nil?
7  test/acts_as_authentic_test/base_test.rb
@@ -14,5 +14,12 @@ def test_acts_as_authentic_with_old_config
14 14
15 15
16 16
+    def test_acts_as_authentic_with_no_table
+      klass =
+      assert_nothing_raised do
+        klass.acts_as_authentic
+      end
+    end
17 24
18 25

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.