Skip to content
This repository

Fix broken migrations caused by #290 #323

Merged
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.

J.

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.

ctilley83

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
ctilley83
James McCarthy

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

Ellis Berner

+5

James Herdman

+1

Tim Olshansky

+1

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 <james2mccarthy@gmail.com>
d1fdc90
This page is out of date. Refresh to see the latest.
1  .gitignore
@@ -7,3 +7,4 @@ coverage/*
7 7
 doc/*
8 8
 benchmarks/*
9 9
 .specification
  10
+.rvmrc
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
31  
-          raise StandardError.new("You must establish a database connection before using acts_as_authentic") if !db_setup?
  31
+          return unless table_exists?
  32
+
  33
+          # Raise an error if you've loaded the model without establishing a valid database connection.
  34
+          raise StandardError.new("You must establish a database connection before using acts_as_authentic") unless connection.present?
32 35
           
33 36
           raise ArgumentError.new("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
         User.acts_as_authentic({})
15 15
       end
16 16
     end
  17
+    
  18
+    def test_acts_as_authentic_with_no_table
  19
+      klass = Class.new(ActiveRecord::Base)
  20
+      assert_nothing_raised do
  21
+        klass.acts_as_authentic
  22
+      end
  23
+    end
17 24
   end
18 25
 end
Commit_comment_tip

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.