Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
9e6afe4f
Commit
9e6afe4f
authored
Aug 19, 2010
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include a module other than top-level Paperclip to prevent namespace collisions.
parent
6868ff95
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
14 deletions
+22
-14
lib/paperclip.rb
+11
-9
lib/paperclip/railtie.rb
+1
-1
test/helper.rb
+4
-4
test/paperclip_test.rb
+6
-0
No files found.
lib/paperclip.rb
View file @
9e6afe4f
...
...
@@ -103,15 +103,6 @@ module Paperclip
CommandLine
.
new
(
cmd
,
*
params
).
run
end
def
included
base
#:nodoc:
base
.
extend
ClassMethods
if
base
.
respond_to?
(
"set_callback"
)
base
.
send
:include
,
Paperclip
::
CallbackCompatability
::
Rails3
else
base
.
send
:include
,
Paperclip
::
CallbackCompatability
::
Rails21
end
end
def
processor
name
#:nodoc:
name
=
name
.
to_s
.
camelize
processor
=
Paperclip
.
const_get
(
name
)
...
...
@@ -159,6 +150,17 @@ module Paperclip
class
InfiniteInterpolationError
<
PaperclipError
#:nodoc:
end
module
Glue
def
self
.
included
base
#:nodoc:
base
.
extend
ClassMethods
if
base
.
respond_to?
(
"set_callback"
)
base
.
send
:include
,
Paperclip
::
CallbackCompatability
::
Rails3
else
base
.
send
:include
,
Paperclip
::
CallbackCompatability
::
Rails21
end
end
end
module
ClassMethods
# +has_attached_file+ gives the class it is called on an attribute that maps to a file. This
# is typically a file stored somewhere on the filesystem and has been uploaded by a user.
...
...
lib/paperclip/railtie.rb
View file @
9e6afe4f
...
...
@@ -17,7 +17,7 @@ module Paperclip
class
Railtie
def
self
.
insert
ActiveRecord
::
Base
.
send
(
:include
,
Paperclip
)
ActiveRecord
::
Base
.
send
(
:include
,
Paperclip
::
Glue
)
File
.
send
(
:include
,
Paperclip
::
Upfile
)
end
end
...
...
test/helper.rb
View file @
9e6afe4f
...
...
@@ -61,10 +61,10 @@ ActiveRecord::Base.logger = ActiveSupport::BufferedLogger.new(File.dirname(__FIL
ActiveRecord
::
Base
.
establish_connection
(
config
[
'test'
])
def
reset_class
class_name
ActiveRecord
::
Base
.
send
(
:include
,
Paperclip
)
ActiveRecord
::
Base
.
send
(
:include
,
Paperclip
::
Glue
)
Object
.
send
(
:remove_const
,
class_name
)
rescue
nil
klass
=
Object
.
const_set
(
class_name
,
Class
.
new
(
ActiveRecord
::
Base
))
klass
.
class_eval
{
include
Paperclip
}
klass
.
class_eval
{
include
Paperclip
::
Glue
}
klass
end
...
...
@@ -90,11 +90,11 @@ def rebuild_model options = {}
end
def
rebuild_class
options
=
{}
ActiveRecord
::
Base
.
send
(
:include
,
Paperclip
)
ActiveRecord
::
Base
.
send
(
:include
,
Paperclip
::
Glue
)
Object
.
send
(
:remove_const
,
"Dummy"
)
rescue
nil
Object
.
const_set
(
"Dummy"
,
Class
.
new
(
ActiveRecord
::
Base
))
Dummy
.
class_eval
do
include
Paperclip
include
Paperclip
::
Glue
has_attached_file
:avatar
,
options
end
end
...
...
test/paperclip_test.rb
View file @
9e6afe4f
...
...
@@ -172,6 +172,12 @@ class PaperclipTest < Test::Unit::TestCase
end
end
should
"not have Attachment in the ActiveRecord::Base namespace"
do
assert_raises
(
NameError
)
do
ActiveRecord
::
Base
::
Attachment
end
end
def
self
.
should_validate
validation
,
options
,
valid_file
,
invalid_file
context
"with
#{
validation
}
validation and
#{
options
.
inspect
}
options"
do
setup
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment