Is there a way I can dynamically define the “store_dir” based on the
model? For example, if I have “user”, “product” and “place” models all
of which HATBTM “picture”, I’d like uploads to be located in:
public/picture/user/1/filename.jpg ## user pic
public/picture/product/6/filename.jpg ## product pic
public/picture/place/102/filename.jpg ## place pic
Thanks a lot! You’re always helpful. One more thing… setting the
store_dir does what I want, almost. With this I can set the path prefix,
but for the id, it’s still using the id from the “Picture” class. Is
there a way I can have this use the id from the user, place, profile,
etc… class insstead?
Upload goes to:
picture/user/PICTURE_ID/filename
can I set it to go to:
picture/user/USER_ID/filename (if I know I’m dealing with the “user”
class, etc… )
I’m using store_dir => :my_store …which saves the files in the right
location, but url_for_image_column seems to be disregarding this. For
example, I’m telling store_dir to use ‘/pictures/user’, but
url_for_image_column is still looking in ‘/picture/filename’.
Second, I’m using Switchtower to manage deployment. My pictures are
stored in /pics, but I don’t want pictures in svn. Each new release is
deployed with an empty /pics dir, and I have to copy over the pictures
manually. Do you have a suggestion for dealing with this? Can
file_column store pictures in a directory outside of RAILS_ROOT without
much trouble (didnt seem like the helpers would adapt to this
situation), or maybe I should just use a symlink.
I would imagine that to require a source patch. I would suspect that
you’re putting too much thought into this. I’d just use it as it
works, or, if you’re converting a legacy structure, write a simple
ruby script to restructure your files.
–
Kyle M.
Chief Technologist
E Factor Media // FN Interactive [email protected]
1-866-263-3261
Second, I’m using Switchtower to manage deployment. My pictures are
stored in /pics, but I don’t want pictures in svn. Each new release is
deployed with an empty /pics dir, and I have to copy over the pictures
manually. Do you have a suggestion for dealing with this? Can
file_column store pictures in a directory outside of RAILS_ROOT without
much trouble (didnt seem like the helpers would adapt to this
situation), or maybe I should just use a symlink.
symlink to the shared directory. switchtower can do the linking for
you.