Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
Automatic initialization for Rails 2 and Rails 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Yurek committed May 20, 2010
1 parent aa93dae commit b9d9fc4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
5 changes: 2 additions & 3 deletions lib/paperclip.rb
Expand Up @@ -37,6 +37,7 @@
require 'paperclip/style' require 'paperclip/style'
require 'paperclip/attachment' require 'paperclip/attachment'
require 'paperclip/callback_compatability' require 'paperclip/callback_compatability'
require 'paperclip/railtie'
if defined?(Rails.root) && Rails.root if defined?(Rails.root) && Rails.root
Dir.glob(File.join(File.expand_path(Rails.root), "lib", "paperclip_processors", "*.rb")).each do |processor| Dir.glob(File.join(File.expand_path(Rails.root), "lib", "paperclip_processors", "*.rb")).each do |processor|
require processor require processor
Expand All @@ -47,7 +48,7 @@
# documentation for Paperclip::ClassMethods for more useful information. # documentation for Paperclip::ClassMethods for more useful information.
module Paperclip module Paperclip


VERSION = "2.3.2" VERSION = "2.3.2.beta1"


class << self class << self
# Provides configurability to Paperclip. There are a number of options available, such as: # Provides configurability to Paperclip. There are a number of options available, such as:
Expand All @@ -71,8 +72,6 @@ def options
end end


def configure def configure
ActiveRecord::Base.send(:include, Paperclip)
File.send(:include, Paperclip::Upfile)
yield(self) if block_given? yield(self) if block_given?
end end


Expand Down
20 changes: 20 additions & 0 deletions lib/paperclip/railtie.rb
@@ -0,0 +1,20 @@
require 'paperclip'

module Paperclip
if defined? Rails::Railtie
require 'rails'
class Railtie < Rails::Railtie
config.after_initialize do
Paperclip::Railtie.insert
end
end
end

class Railtie
def self.insert
ActiveRecord::Base.send(:include, Paperclip)
File.send(:include, Paperclip::Upfile)
end
end
end

2 changes: 1 addition & 1 deletion paperclip.gemspec
@@ -1,7 +1,7 @@
$LOAD_PATH << File.join(File.dirname(__FILE__), 'lib') $LOAD_PATH << File.join(File.dirname(__FILE__), 'lib')
require 'paperclip' require 'paperclip'


include_files = ["README*", "LICENSE", "Rakefile", "init.rb", "{generators,lib,tasks,test,shoulda_macros}/**/*"].map do |glob| include_files = ["README*", "LICENSE", "Rakefile", "init.rb", "{lib,tasks,test,rails,generators,shoulda_macros}/**/*"].map do |glob|
Dir[glob] Dir[glob]
end.flatten end.flatten
exclude_files = ["test/s3.yml", "test/debug.log", "test/paperclip.db", "test/doc", "test/doc/*", "test/pkg", "test/pkg/*", "test/tmp", "test/tmp/*"].map do |glob| exclude_files = ["test/s3.yml", "test/debug.log", "test/paperclip.db", "test/doc", "test/doc/*", "test/pkg", "test/pkg/*", "test/tmp", "test/tmp/*"].map do |glob|
Expand Down
2 changes: 2 additions & 0 deletions rails/init.rb
@@ -0,0 +1,2 @@
require 'paperclip/railtie'
Paperclip::Railtie.insert

0 comments on commit b9d9fc4

Please sign in to comment.