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
ffb0e01b
Commit
ffb0e01b
authored
Aug 01, 2008
by
Henrik N
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Shorten !attachment.original_filename.blank? to attachment.file?
parent
71adf38c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
4 deletions
+9
-4
lib/paperclip.rb
+4
-3
lib/paperclip/attachment.rb
+5
-1
No files found.
lib/paperclip.rb
View file @
ffb0e01b
...
...
@@ -135,7 +135,7 @@ module Paperclip
end
define_method
"
#{
name
}
?"
do
!
attachment_for
(
name
).
original_filename
.
blank
?
attachment_for
(
name
).
file
?
end
validates_each
(
name
)
do
|
record
,
attr
,
value
|
...
...
@@ -157,7 +157,8 @@ module Paperclip
unless
options
[
:less_than
].
nil?
options
[
:in
]
=
(
0
..
options
[
:less_than
])
end
unless
attachment
.
original_filename
.
blank?
||
options
[
:in
].
include?
(
instance
[
:"
#{
name
}
_file_size"
].
to_i
)
if
attachment
.
file?
&&
!
options
[
:in
].
include?
(
instance
[
:"
#{
name
}
_file_size"
].
to_i
)
min
=
options
[
:in
].
first
max
=
options
[
:in
].
last
...
...
@@ -178,7 +179,7 @@ module Paperclip
# Places ActiveRecord-style validations on the presence of a file.
def
validates_attachment_presence
name
,
options
=
{}
attachment_definitions
[
name
][
:validations
]
<<
lambda
do
|
attachment
,
instance
|
if
attachment
.
original_filename
.
blank
?
unless
attachment
.
file
?
options
[
:message
]
||
"must be set."
end
end
...
...
lib/paperclip/attachment.rb
View file @
ffb0e01b
...
...
@@ -187,6 +187,10 @@ module Paperclip
true
end
end
def
file?
!
original_filename
.
blank?
end
private
...
...
@@ -249,7 +253,7 @@ module Paperclip
end
def
queue_existing_for_delete
#:nodoc:
return
if
original_filename
.
blank
?
return
unless
file
?
logger
.
info
(
"[paperclip] Queueing the existing files for
#{
name
}
for deletion."
)
@queued_for_delete
+=
[
:original
,
*
@styles
.
keys
].
uniq
.
map
do
|
style
|
path
(
style
)
if
exists?
(
style
)
...
...
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