How do I change the file naming scheme (add another paperclip-like identifier)?

275 views
Skip to first unread message

dblock

unread,
Mar 18, 2011, 5:22:22 PM3/18/11
to carrierwave
First, carrierwave = awesome.

Now :) I would like to change the naming
from :class/:id/:style.:extension to something
like :class/:slug/:style.:extension. Slug is a property of my model.
Unfortunately it seems that paperclip compatibility is a hardcoded
list of models.

Is there a way to change the file naming/location scheme? I'd be ok
with a hack.

Thx
dB.

Jonas Nicklas

unread,
Mar 18, 2011, 9:20:24 PM3/18/11
to carri...@googlegroups.com, dblock
You should override the store_dir method in your model, as suggested
by the generated file.

/Jonas

> --
> You received this message because you are subscribed to the Google Groups "carrierwave" group.
> To post to this group, send email to carri...@googlegroups.com.
> To unsubscribe from this group, send email to carrierwave...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/carrierwave?hl=en.
>
>

dblock

unread,
Mar 19, 2011, 9:41:28 AM3/19/11
to carrierwave
I think what confused me is that the existing code I was looking at
was using Paperclip compatibility (had paperclip_path overridden in
the uploader) and that the README tells to override store_dir in the
Uploader (again), not in the actual class which has the image
attachments. Our uploader is used from two different models, so I
rewrote store_path in the uploader, which worked, but it looks like
that's not the best solution.

I'll give your suggestion a try, sort it all out and try to contribute
a doc change - let me know if something smells wrong here. Thx.

dblock

unread,
Mar 22, 2011, 8:02:17 AM3/22/11
to carrierwave
I think none of these methods let you change the entire path, file
name, etc. I ended up overriding store_path.

dblock

unread,
Mar 22, 2011, 8:02:38 AM3/22/11
to carrierwave
Reply all
Reply to author
Forward
0 new messages