BUGFIX: attachments bust under multisite
This commit is contained in:
parent
14f7551f2b
commit
3830f41e5f
|
@ -30,6 +30,8 @@ class UploadsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
RailsMultisite::ConnectionManagement.with_connection(params[:site]) do |db|
|
||||
|
||||
return render nothing: true, status: 404 unless Discourse.store.internal?
|
||||
|
||||
id = params[:id].to_i
|
||||
|
@ -41,6 +43,8 @@ class UploadsController < ApplicationController
|
|||
return render nothing: true, status: 404 unless upload
|
||||
|
||||
send_file(Discourse.store.path_for(upload), filename: upload.original_filename)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -42,6 +42,14 @@ server {
|
|||
# path to discourse's public directory
|
||||
set $public /var/www/discourse/public;
|
||||
|
||||
# prep all possible needed proxy headers
|
||||
# this is critical form multisite
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $thescheme;
|
||||
|
||||
|
||||
location / {
|
||||
root $public;
|
||||
|
||||
|
@ -98,11 +106,6 @@ server {
|
|||
}
|
||||
|
||||
location @discourse {
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $thescheme;
|
||||
|
||||
proxy_pass http://discourse;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,12 +35,15 @@ module RailsMultisite
|
|||
old = current_db
|
||||
connected = ActiveRecord::Base.connection_pool.connected?
|
||||
|
||||
establish_connection(:db => db)
|
||||
establish_connection(:db => db) unless connected && db == old
|
||||
rval = yield db
|
||||
|
||||
unless connected && db == old
|
||||
ActiveRecord::Base.connection_handler.clear_active_connections!
|
||||
|
||||
establish_connection(:db => old)
|
||||
ActiveRecord::Base.connection_handler.clear_active_connections! unless connected
|
||||
end
|
||||
|
||||
rval
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue