diff --git a/lib/paperclip/interpolations.rb b/lib/paperclip/interpolations.rb index 5291cfcf2..8a90e23bf 100644 --- a/lib/paperclip/interpolations.rb +++ b/lib/paperclip/interpolations.rb @@ -63,7 +63,10 @@ def rails_env attachment, style # Returns the underscored, pluralized version of the class name. # e.g. "users" for the User class. - def class attachment, style + # NOTE: The arguments need to be optional, because some tools fetch + # all class names. Calling #class will return the expected class. + def class attachment = nil, style = nil + return super() if attachment.nil? && style.nil? attachment.instance.class.to_s.underscore.pluralize end diff --git a/test/interpolations_test.rb b/test/interpolations_test.rb index 37b5e0696..04f054219 100644 --- a/test/interpolations_test.rb +++ b/test/interpolations_test.rb @@ -19,6 +19,10 @@ class InterpolationsTest < Test::Unit::TestCase assert_equal RAILS_ENV, Paperclip::Interpolations.rails_env(:attachment, :style) end + should "return the class of the Interpolations module when called with no params" do + assert_equal Module, Paperclip::Interpolations.class + end + should "return the class of the instance" do attachment = mock attachment.expects(:instance).returns(attachment)