ruby on rails 3 - Carrierwave dynamic storage type via model attributes -


i want save photographs in 'grid_fs' , other types of files 'fog', like:

class documentuploader < carrierwave::uploader::base   def storage     if model.is_photograph == true       :grid_fs     else       :fog     end    end end 

is possible?

i want dynamically assign storage type model attributes, , i've tried this, model , attributes not accessible in class method.

thanks!

the quick answer "no". unlike store_dir, validate_integrity et al, storage isn't sent through add_config, , doesn't of instance-level magic make easy.

it might possible, come fragile hack. you're better off looking @ other ways support feature (multiple uploaders?) or changing specification.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -