You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
revis0r edited this page May 16, 2012
·
3 revisions
If you are use multiple databases in your Rails application, it's important to save files in different directories, for example named like subdomains. This is my example solution:
ApplicationController.rb
def override_db
...
redefine_uploaders_store_dir
end
def redefine_uploaders_store_dir
CarrierWave::Uploader::Base.descendants.each do |d|
d.class_eval <<-RUBY, __FILE__, __LINE__+1
def store_dir
"uploads/#{@current_subdomain}/\#{model.class.to_s.underscore}/\#{mounted_as}/\#{model.id}"
end
RUBY
end
end