From 3b36af5ceb3d23d4834984bff9aa90c70dea3720 Mon Sep 17 00:00:00 2001 From: Gregory Man Date: Fri, 8 Aug 2008 03:58:07 +0300 Subject: [PATCH] Add instance_methods check in addition to column_names check --- lib/paperclip.rb | 2 +- test/paperclip_test.rb | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/paperclip.rb b/lib/paperclip.rb index 2b458d8..365c411 100644 --- a/lib/paperclip.rb +++ b/lib/paperclip.rb @@ -114,7 +114,7 @@ module Paperclip include InstanceMethods %w(file_name).each do |field| - unless column_names.include?("#{name}_#{field}") + unless column_names.include?("#{name}_#{field}") || self.instance_methods.include?("#{name}_#{field}") raise PaperclipError.new("#{self} model does not have required column '#{name}_#{field}'") end end diff --git a/test/paperclip_test.rb b/test/paperclip_test.rb index 155bead..c2748d9 100644 --- a/test/paperclip_test.rb +++ b/test/paperclip_test.rb @@ -14,7 +14,16 @@ class PaperclipTest < Test::Unit::TestCase end end end - + + should "not error when trying to also create a 'blah' attachment with blah_file_name method" do + assert_nothing_raised do + Dummy.class_eval do + def blah_file_name;"test.jpg";end + has_attached_file :blah + end + end + end + context "that is attr_protected" do setup do Dummy.class_eval do -- 1.5.4.3