Commit 2ff75d11 by Jon Yurek

has_attached_file will raise if the _file_size and _content_type fields don't exist.

parent 9b3c51d7
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment