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
b8506d36
Commit
b8506d36
authored
Dec 29, 2008
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a callback compatability shim for older versions of Rails
parent
1d023306
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
1 deletions
+35
-1
lib/paperclip.rb
+1
-0
lib/paperclip/attachment.rb
+1
-1
lib/paperclip/callback_compatability.rb
+33
-0
No files found.
lib/paperclip.rb
View file @
b8506d36
...
@@ -83,6 +83,7 @@ module Paperclip
...
@@ -83,6 +83,7 @@ module Paperclip
def
included
base
#:nodoc:
def
included
base
#:nodoc:
base
.
extend
ClassMethods
base
.
extend
ClassMethods
base
.
send
(
:include
,
Paperclip
::
CallbackCompatability
)
unless
base
.
respond_to?
(
:define_callbacks
)
end
end
def
processor
name
def
processor
name
...
...
lib/paperclip/attachment.rb
View file @
b8506d36
...
@@ -97,7 +97,7 @@ module Paperclip
...
@@ -97,7 +97,7 @@ module Paperclip
# and can point to an action in your app, if you need fine grained security.
# and can point to an action in your app, if you need fine grained security.
# This is not recommended if you don't need the security, however, for
# This is not recommended if you don't need the security, however, for
# performance reasons.
# performance reasons.
# set include_updated_timestamp to false if you want to stop the attachment update time appended to the url
# set include_updated_timestamp to false if you want to stop the attachment update time appended to the url
def
url
style
=
default_style
,
include_updated_timestamp
=
true
def
url
style
=
default_style
,
include_updated_timestamp
=
true
url
=
original_filename
.
nil?
?
interpolate
(
@default_url
,
style
)
:
interpolate
(
@url
,
style
)
url
=
original_filename
.
nil?
?
interpolate
(
@default_url
,
style
)
:
interpolate
(
@url
,
style
)
include_updated_timestamp
&&
updated_at
?
[
url
,
updated_at
].
compact
.
join
(
url
.
include?
(
"?"
)
?
"&"
:
"?"
)
:
url
include_updated_timestamp
&&
updated_at
?
[
url
,
updated_at
].
compact
.
join
(
url
.
include?
(
"?"
)
?
"&"
:
"?"
)
:
url
...
...
lib/paperclip/callback_compatability.rb
0 → 100644
View file @
b8506d36
module
Paperclip
# This module is intended as a compatability shim for the differences in callbacks
# between Rails 2.0 and Rails 2.1.
module
CallbackCompatability
def
self
.
included
(
base
)
base
.
extend
(
ClassMethods
)
base
.
send
(
:include
,
InstanceMethods
)
end
module
ClassMethods
# The implementation of this method is taken from the Rails 1.2.6 source,
# from rails/activerecord/lib/active_record/callbacks.rb, line 192.
def
define_callbacks
(
*
args
)
args
.
each
do
|
method
|
self
.
class_eval
<<-
"end_eval"
def self.
#{
method
}
(*callbacks, &block)
callbacks << block if block_given?
write_inheritable_array(
#{
method
.
to_sym
.
inspect
}
, callbacks)
end
end_eval
end
end
end
module
InstanceMethods
# The callbacks in < 2.1 don't worry about the extra options or the
# block, so just run what we have available.
def
run_callbacks
(
meth
,
opts
=
nil
,
&
blk
)
callback
(
meth
)
end
end
end
end
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