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
cd534851
Commit
cd534851
authored
Oct 20, 2011
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Errors on presence get added to :attachment and :attachment_file_name
parent
61a05368
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletions
+5
-1
lib/paperclip.rb
+4
-1
test/paperclip_test.rb
+1
-0
No files found.
lib/paperclip.rb
View file @
cd534851
...
...
@@ -390,7 +390,10 @@ module Paperclip
validates_each
:"
#{
name
}
_file_name"
do
|
record
,
attr
,
value
|
if_clause_passed
=
options
[
:if
].
nil?
||
(
options
[
:if
].
call
(
record
)
!=
false
)
unless_clause_passed
=
options
[
:unless
].
nil?
||
(
!!
options
[
:unless
].
call
(
record
)
==
false
)
record
.
errors
.
add
(
name
,
message
)
if
if_clause_passed
&&
unless_clause_passed
&&
value
.
blank?
if
if_clause_passed
&&
unless_clause_passed
&&
value
.
blank?
record
.
errors
.
add
(
name
,
message
)
record
.
errors
.
add
(
"
#{
name
}
_file_name"
,
message
)
end
end
end
...
...
test/paperclip_test.rb
View file @
cd534851
...
...
@@ -225,6 +225,7 @@ class PaperclipTest < Test::Unit::TestCase
end
if
validation
==
:presence
should
"have an error on the attachment"
do
assert
@dummy
.
errors
[
:avatar
]
assert
@dummy
.
errors
[
:avatar_file_name
]
end
else
...
...
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