Skip to content
Browse files

Revert "Handle interpolation of string IDs (supports mongo) as well a…

…s integers"

This reverts commit fe01ae6.
  • Loading branch information...
1 parent e365326 commit cde225648190982caa6a9cc33aff70973fd28695 Harold Giménez committed Aug 15, 2011
Showing with 2 additions and 13 deletions.
  1. +1 −5 lib/paperclip/interpolations.rb
  2. +1 −8 test/interpolations_test.rb
View
6 lib/paperclip/interpolations.rb
@@ -143,11 +143,7 @@ def hash attachment, style_name
# Returns the id of the instance in a split path form. e.g. returns
# 000/001/234 for an id of 1234.
def id_partition attachment, style_name
- if (id = attachment.instance.id).is_a?(Integer)
- ("%09d" % id).scan(/\d{3}/).join("/")
- else
- id.scan(/.{3}/).first(3).join("/")
- end
+ ("%09d" % attachment.instance.id).scan(/\d{3}/).join("/")
end
# Returns the pluralized form of the attachment name. e.g.
View
9 test/interpolations_test.rb
@@ -88,20 +88,13 @@ class InterpolationsTest < Test::Unit::TestCase
assert_equal 23, Paperclip::Interpolations.id(attachment, :style)
end
- should "return the partitioned id of the attachment when the id is an integer" do
+ should "return the partitioned id of the attachment" do
attachment = mock
attachment.expects(:id).returns(23)
attachment.expects(:instance).returns(attachment)
assert_equal "000/000/023", Paperclip::Interpolations.id_partition(attachment, :style)
end
- should "return the partitioned id of the attachment when the id is a string" do
- attachment = mock
- attachment.expects(:id).returns("32fnj23oio2f")
- attachment.expects(:instance).returns(attachment)
- assert_equal "32f/nj2/3oi", Paperclip::Interpolations.id_partition(attachment, :style)
- end
-
should "return the name of the attachment" do
attachment = mock
attachment.expects(:name).returns("file")

4 comments on commit cde2256

@sikachu
thoughtbot, inc. member

Why was this got reverted?

@hgmnz
hgmnz commented on cde2256 Aug 16, 2011

This was sitting on my local master branch for ages. Back when I was doing mongo, imagine that.

I git pulled, which defaulted to a git pull --rebase, and then git push'ed a README change (and this commit slipped right in). I hadn't really looked over this commit in detail recently, so decided to back out.

Feel free to revert this revert though.

@sikachu
thoughtbot, inc. member

Ah ok, I was curious as I thought you were fixing something for MongoDB.

@hgmnz
hgmnz commented on cde2256 Aug 16, 2011

I was...over a year ago.

Please sign in to comment.
Something went wrong with that request. Please try again.