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
2ff75d11
Commit
2ff75d11
authored
Jul 25, 2008
by
Jon Yurek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
has_attached_file will raise if the _file_size and _content_type fields don't exist.
parent
9b3c51d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
lib/paperclip.rb
+6
-0
test/paperclip_test.rb
+8
-0
No files found.
lib/paperclip.rb
View file @
2ff75d11
...
...
@@ -113,6 +113,12 @@ module Paperclip
def
has_attached_file
name
,
options
=
{}
include
InstanceMethods
%w(file_name content_type)
.
each
do
|
field
|
unless
column_names
.
include?
(
"
#{
name
}
_
#{
field
}
"
)
raise
PaperclipError
.
new
(
"
#{
self
}
model does not have required column '
#{
name
}
_
#{
field
}
'"
)
end
end
write_inheritable_attribute
(
:attachment_definitions
,
{})
if
attachment_definitions
.
nil?
attachment_definitions
[
name
]
=
{
:validations
=>
[]}.
merge
(
options
)
...
...
test/paperclip_test.rb
View file @
2ff75d11
...
...
@@ -7,6 +7,14 @@ class PaperclipTest < Test::Unit::TestCase
@file
=
File
.
new
(
File
.
join
(
FIXTURES_DIR
,
"5k.png"
))
end
should
"error when trying to also create a 'blah' attachment"
do
assert_raises
(
Paperclip
::
PaperclipError
)
do
Dummy
.
class_eval
do
has_attached_file
:blah
end
end
end
context
"that is attr_protected"
do
setup
do
Dummy
.
class_eval
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