Commit fd6eba32 by Prem Sichanugrist

Fix problem occurred from undefined `inheritable_attributes` in Rails 2.3.x after the last merge

parent ddef840b
...@@ -132,7 +132,7 @@ module Paperclip ...@@ -132,7 +132,7 @@ module Paperclip
def logging? #:nodoc: def logging? #:nodoc:
options[:log] options[:log]
end end
def class_for(class_name) def class_for(class_name)
class_name.split('::').inject(Object) do |klass, partial_class_name| class_name.split('::').inject(Object) do |klass, partial_class_name|
klass.const_get(partial_class_name) klass.const_get(partial_class_name)
...@@ -158,6 +158,7 @@ module Paperclip ...@@ -158,6 +158,7 @@ module Paperclip
module Glue module Glue
def self.included base #:nodoc: def self.included base #:nodoc:
base.extend ClassMethods base.extend ClassMethods
base.class_attribute :attachment_definitions
if base.respond_to?("set_callback") if base.respond_to?("set_callback")
base.send :include, Paperclip::CallbackCompatability::Rails3 base.send :include, Paperclip::CallbackCompatability::Rails3
else else
...@@ -233,7 +234,14 @@ module Paperclip ...@@ -233,7 +234,14 @@ module Paperclip
def has_attached_file name, options = {} def has_attached_file name, options = {}
include InstanceMethods include InstanceMethods
write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil? if attachment_definitions.nil?
if respond_to?(:class_attribute)
self.attachment_definitions = {}
else
write_inheritable_attribute(:attachment_definitions, {})
end
end
attachment_definitions[name] = {:validations => []}.merge(options) attachment_definitions[name] = {:validations => []}.merge(options)
after_save :save_attached_files after_save :save_attached_files
...@@ -341,7 +349,11 @@ module Paperclip ...@@ -341,7 +349,11 @@ module Paperclip
# Returns the attachment definitions defined by each call to # Returns the attachment definitions defined by each call to
# has_attached_file. # has_attached_file.
def attachment_definitions def attachment_definitions
inheritable_attributes[:attachment_definitions] if respond_to?(:class_attribute)
self.attachment_definitions
else
read_inheritable_attribute(:attachment_definitions)
end
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment