public
Description: Paperclip File Management Plugin
Homepage: http://www.thoughtbot.com/projects/paperclip
Clone URL: git://github.com/thoughtbot/paperclip.git
has_attached_file will raise if the _file_size and _content_type fields 
don't exist.
jyurek (author)
Fri Jul 25 08:36:03 -0700 2008
commit  2ff75d116e886e7088e1542fc0f0ee464be53b5c
tree    7bc118f22ca0e1b27fb2c5c0c3eb997c31e18a43
parent  9b3c51d7379c8123eac712480466b6c75242dd1d
...
113
114
115
 
 
 
 
 
 
116
117
118
...
113
114
115
116
117
118
119
120
121
122
123
124
0
@@ -113,6 +113,12 @@ module Paperclip
0
     def has_attached_file name, options = {}
0
       include InstanceMethods
0
 
0
+ %w(file_name content_type).each do |field|
0
+ unless column_names.include?("#{name}_#{field}")
0
+ raise PaperclipError.new("#{self} model does not have required column '#{name}_#{field}'")
0
+ end
0
+ end
0
+
0
       write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil?
0
       attachment_definitions[name] = {:validations => []}.merge(options)
0
 
...
7
8
9
 
 
 
 
 
 
 
 
10
11
12
...
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0
@@ -7,6 +7,14 @@ class PaperclipTest < Test::Unit::TestCase
0
       @file = File.new(File.join(FIXTURES_DIR, "5k.png"))
0
     end
0
 
0
+ should "error when trying to also create a 'blah' attachment" do
0
+ assert_raises(Paperclip::PaperclipError) do
0
+ Dummy.class_eval do
0
+ has_attached_file :blah
0
+ end
0
+ end
0
+ end
0
+
0
     context "that is attr_protected" do
0
       setup do
0
         Dummy.class_eval do

Comments

    No one has commented yet.