Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

id_partition doesn't work with mongodb #757

Closed
ikonyshev opened this issue Feb 27, 2012 · 1 comment
Closed

id_partition doesn't work with mongodb #757

ikonyshev opened this issue Feb 27, 2012 · 1 comment

Comments

@ikonyshev
Copy link

according to code below (it's from interpolations.rb) id_partition function return nil for mongo ids because mongo use own id class. I think it would be great to convert id to string using .to_s to avoid such problems.
Also it seems that taking only first 3 matches for string ids can cause problems (for example my project is going to have 200-300k items with up to 30 images per item, and these 3 matches wouldn't help at all)

    def id_partition attachment, style_name
      case id = attachment.instance.id
      when Integer
        ("%09d" % id).scan(/\d{3}/).join("/")
      when String
        id.scan(/.{3}/).first(3).join("/")
      else
        nil
      end
    end
@sikachu
Copy link
Contributor

sikachu commented Mar 2, 2012

Yeah, I think for mongo you'll have to write the id_partition interpolation yourself, and override the one given by paperclip.

@sikachu sikachu closed this as completed Mar 2, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants