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
c9834ef9
Commit
c9834ef9
authored
Jul 08, 2008
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new task for cleaning out invalid attachments.
parent
13895667
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
6 deletions
+24
-6
lib/paperclip/attachment.rb
+1
-0
tasks/paperclip_tasks.rake
+23
-6
No files found.
lib/paperclip/attachment.rb
View file @
c9834ef9
...
...
@@ -203,6 +203,7 @@ module Paperclip
@styles
.
each
do
|
name
,
args
|
begin
dimensions
,
format
=
args
dimensions
=
dimensions
.
call
(
instance
)
if
dimensions
.
respond_to?
:call
@queued_for_write
[
name
]
=
Thumbnail
.
make
(
@queued_for_write
[
:original
],
dimensions
,
format
,
...
...
tasks/paperclip_tasks.rake
View file @
c9834ef9
...
...
@@ -14,19 +14,15 @@ def obtain_attachments
end
end
namespace
:paperclip
do
desc
"Regenerates thumbnails for a given CLASS (and optional ATTACHMENT)"
task
:refresh
=>
:environment
do
def
for_all_attachments
klass
=
obtain_class
names
=
obtain_attachments
instances
=
klass
.
find
(
:all
)
puts
"Regenerating thumbnails for
#{
instances
.
length
}
instances of
#{
klass
.
name
}
:"
instances
.
each
do
|
instance
|
names
.
each
do
|
name
|
result
=
if
instance
.
send
(
"
#{
name
}
?"
)
instance
.
send
(
name
).
reprocess!
instance
.
send
(
name
).
save
yield
(
instance
,
name
)
else
true
end
...
...
@@ -34,5 +30,26 @@ namespace :paperclip do
end
end
puts
" Done."
end
namespace
:paperclip
do
desc
"Regenerates thumbnails for a given CLASS (and optional ATTACHMENT)"
task
:refresh
=>
:environment
do
for_all_attachments
do
|
instance
,
name
|
instance
.
send
(
name
).
reprocess!
instance
.
send
(
name
).
save
end
end
desc
"Cleans out invalid attachments. Useful after you've added new validations."
task
:clean
=>
:environment
do
for_all_attachments
do
|
instance
,
name
|
if
instance
.
valid?
true
else
instance
.
send
(
"
#{
name
}
="
,
nil
)
instance
.
save
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