Skip to content
This repository

Rails 3.1 Compatibility #254

Merged
merged 3 commits into from almost 3 years ago

5 participants

Andreas Wurm Vagner Zampieri Fernando Kosh Binary Logic Dave Busse
Andreas Wurm

No description provided.

Vagner Zampieri

Hey binarylogic, can you apply this patch? I want to use AuthLogic with Rails 3.1.0-beta, but without this patch it's does work. I got this message when run bundler install:

Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
authlogic (= 3.0.2) depends on
activerecord (~> 3.0.7)

rails depends on
  activerecord (3.1.0.beta)

Tks

Fernando Kosh

Vagner, We can use a branch of AndreasWurm for now.
Please aplly this patch, BynaryLogic.

Binary Logic
Owner

Can you explain what you're doing in this commit:

AndreasWurm@7b114e7

Thats the reason I haven't merged it in. I already merged in more relaxed dependencies on rails 3. Thanks.

Andreas Wurm

ive converted the whole inheritable_attribute thing to use class_attribute (which also supports inheritance).
also added a logger to AR cause it required it.

Binary Logic binarylogic merged commit c569334 into from May 17, 2011
Binary Logic binarylogic closed this May 17, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
2  Gemfile
... ...
@@ -1,6 +1,6 @@
1 1
 source :rubygems
2 2
 
3  
-gem 'activerecord', '~> 3.0.7'
  3
+gem 'activerecord', '>= 3.0.7'
4 4
 
5 5
 group :test do
6 6
   gem 'bcrypt-ruby'
2  Gemfile.lock
@@ -42,7 +42,7 @@ PLATFORMS
42 42
   ruby
43 43
 
44 44
 DEPENDENCIES
45  
-  activerecord (~> 3.0.7)
  45
+  activerecord (>= 3.0.7)
46 46
   bcrypt-ruby
47 47
   jeweler
48 48
   ruby-debug19
12  authlogic.gemspec
@@ -206,15 +206,15 @@ Gem::Specification.new do |s|
206 206
     s.specification_version = 3
207 207
 
208 208
     if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
209  
-      s.add_runtime_dependency(%q<activerecord>, ["~> 3.0.7"])
210  
-      s.add_runtime_dependency(%q<activerecord>, ["~> 3.0.7"])
  209
+      s.add_runtime_dependency(%q<activerecord>, [">= 3.0.7"])
  210
+      s.add_runtime_dependency(%q<activerecord>, [">= 3.0.7"])
211 211
     else
212  
-      s.add_dependency(%q<activerecord>, ["~> 3.0.7"])
213  
-      s.add_dependency(%q<activerecord>, ["~> 3.0.7"])
  212
+      s.add_dependency(%q<activerecord>, [">= 3.0.7"])
  213
+      s.add_dependency(%q<activerecord>, [">= 3.0.7"])
214 214
     end
215 215
   else
216  
-    s.add_dependency(%q<activerecord>, ["~> 3.0.7"])
217  
-    s.add_dependency(%q<activerecord>, ["~> 3.0.7"])
  216
+    s.add_dependency(%q<activerecord>, [">= 3.0.7"])
  217
+    s.add_dependency(%q<activerecord>, [">= 3.0.7"])
218 218
   end
219 219
 end
220 220
 
26  lib/authlogic/acts_as_authentic/base.rb
@@ -4,6 +4,9 @@ module ActsAsAuthentic
4 4
     module Base
5 5
       def self.included(klass)
6 6
         klass.class_eval do
  7
+          class_attribute :acts_as_authentic_modules, :acts_as_authentic_config
  8
+          self.acts_as_authentic_modules ||= []
  9
+          self.acts_as_authentic_config  ||= {}
7 10
           extend Config
8 11
         end
9 12
       end
@@ -41,7 +44,7 @@ def acts_as_authentic(unsupported_options = nil, &block)
41 44
         #
42 45
         # That being said, this is your tool for extending Authlogic and "hooking" into the acts_as_authentic call.
43 46
         def add_acts_as_authentic_module(mod, action = :append)
44  
-          modules = acts_as_authentic_modules
  47
+          modules = acts_as_authentic_modules.clone
45 48
           case action
46 49
           when :append
47 50
             modules << mod
@@ -49,21 +52,17 @@ def add_acts_as_authentic_module(mod, action = :append)
49 52
             modules = [mod] + modules
50 53
           end
51 54
           modules.uniq!
52  
-          write_inheritable_attribute(:acts_as_authentic_modules, modules)
  55
+          self.acts_as_authentic_modules = modules
53 56
         end
54 57
         
55 58
         # This is the same as add_acts_as_authentic_module, except that it removes the module from the list.
56 59
         def remove_acts_as_authentic_module(mod)
57  
-          acts_as_authentic_modules.delete(mod)
58  
-          acts_as_authentic_modules
  60
+          modules = acts_as_authentic_modules.clone
  61
+          modules.delete(mod)
  62
+          self.acts_as_authentic_modules = modules
59 63
         end
60  
-        
  64
+
61 65
         private
62  
-          def acts_as_authentic_modules
63  
-            key = :acts_as_authentic_modules
64  
-            inheritable_attributes.include?(key) ? read_inheritable_attribute(key) : []
65  
-          end
66  
-          
67 66
           def db_setup?
68 67
             begin
69 68
               column_names
@@ -75,9 +74,12 @@ def db_setup?
75 74
           
76 75
           def rw_config(key, value, default_value = nil, read_value = nil)
77 76
             if value == read_value
78  
-              inheritable_attributes.include?(key) ? read_inheritable_attribute(key) : default_value
  77
+              acts_as_authentic_config.include?(key) ? acts_as_authentic_config[key] : default_value
79 78
             else
80  
-              write_inheritable_attribute(key, value)
  79
+              config = acts_as_authentic_config.clone
  80
+              config[key] = value
  81
+              self.acts_as_authentic_config = config
  82
+              value
81 83
             end
82 84
           end
83 85
           
12  lib/authlogic/session/foundation.rb
@@ -6,6 +6,9 @@ module Session
6 6
     module Foundation
7 7
       def self.included(klass)
8 8
         klass.class_eval do
  9
+          class_attribute :acts_as_authentic_config
  10
+          self.acts_as_authentic_config  ||= {}
  11
+          
9 12
           extend ClassMethods
10 13
           include InstanceMethods
11 14
         end
@@ -15,10 +18,13 @@ module ClassMethods
15 18
         private
16 19
           def rw_config(key, value, default_value = nil, read_value = nil)
17 20
             if value == read_value
18  
-              return read_inheritable_attribute(key) if inheritable_attributes.include?(key)
19  
-              write_inheritable_attribute(key, default_value)
  21
+              return acts_as_authentic_config[key] if acts_as_authentic_config.include?(key)
  22
+              rw_config(key, default_value)
20 23
             else
21  
-              write_inheritable_attribute(key, value)
  24
+              config = acts_as_authentic_config.clone
  25
+              config[key] = value
  26
+              self.acts_as_authentic_config = config
  27
+              value
22 28
             end
23 29
           end
24 30
       end
3  test/test_helper.rb
@@ -6,6 +6,9 @@
6 6
 
7 7
 #ActiveRecord::Schema.verbose = false
8 8
 ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
  9
+logger = Logger.new(STDOUT)
  10
+logger.level= Logger::FATAL
  11
+ActiveRecord::Base.logger = logger
9 12
 
10 13
 ActiveRecord::Base.configurations = true
11 14
 ActiveRecord::Schema.define(:version => 1) do
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.