Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix inconsistencies with serving images in production mode when ActiveRecord is loaded #1764

Merged
merged 1 commit into from

2 participants

@stevehodgkiss

Fix inconsistencies by being polite to the wrapped body. Needed for Rack::Sendfile to function properly. See issue #1761.

When active record isn't loaded assets aren't served in production mode, when it is loaded they are... It's debatable whether this is a bug or a feature, but I think it should behave the same whether active record is loaded or not :)

@josevalim josevalim merged commit 4054435 into rails:master
@josevalim
Owner

Could you please provide a pull request for 3-1-stable?

@josevalim josevalim merged commit 5044420 into rails:master
@jake3030 jake3030 referenced this pull request from a commit in jake3030/rails
@pixeltrix pixeltrix Use Path rather than EagerPath when cache_classes == false so other v…
…iew paths are properly recompiled in development mode [#1764 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
bccd2c5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 18, 2011
  1. @stevehodgkiss

    Fix inconsistencies by being polite to the wrapped body. Needed for R…

    stevehodgkiss authored
    …ack::Sendfile to function properly. See issue #1761.
This page is out of date. Refresh to see the latest.
View
8 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -426,6 +426,14 @@ def initialize(body, testing = false)
@testing = testing
end
+ def method_missing(method_sym, *arguments, &block)
+ @body.send(method_sym, *arguments, &block)
+ end
+
+ def respond_to?(method_sym, include_private = false)
+ super || @body.respond_to?(method_sym)
+ end
+
def each(&block)
body.each(&block)
end
View
8 activerecord/lib/active_record/query_cache.rb
@@ -33,6 +33,14 @@ def initialize(original_cache_value, target)
@target = target
end
+ def method_missing(method_sym, *arguments, &block)
+ @target.send(method_sym, *arguments, &block)
+ end
+
+ def respond_to?(method_sym, include_private = false)
+ super || @target.respond_to?(method_sym)
+ end
+
def each(&block)
@target.each(&block)
end
View
7 activerecord/test/cases/connection_management_test.rb
@@ -77,6 +77,13 @@ def test_connections_not_closed_if_exception_and_test
@management.call(@env)
assert ActiveRecord::Base.connection_handler.active_connections?
end
+
+ test "proxy is polite to it's body and responds to it" do
+ body = Class.new(String) { def to_path; "/path"; end }.new
+ proxy = ConnectionManagement::Proxy.new(body)
+ assert proxy.respond_to?(:to_path)
+ assert_equal proxy.to_path, "/path"
+ end
end
end
end
View
11 activerecord/test/cases/query_cache_test.rb
@@ -203,3 +203,14 @@ def test_cache_is_expired_by_habtm_delete
end
end
end
+
+class QueryCacheBodyProxyTest < ActiveRecord::TestCase
+
+ test "is polite to it's body and responds to it" do
+ body = Class.new(String) { def to_path; "/path"; end }.new
+ proxy = ActiveRecord::QueryCache::BodyProxy.new(nil, body)
+ assert proxy.respond_to?(:to_path)
+ assert_equal proxy.to_path, "/path"
+ end
+
+end
Something went wrong with that request. Please try again.