diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-06-01 22:01:40 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-06-01 22:01:40 +0000 |
commit | c9eb5a083f0cf120fe7c3c1e19ead5cfc777b1fe (patch) | |
tree | bce3b598514cafe881c45a6b12d70a315b4c1d8c | |
parent | ef5317f74f83d73484e32a69079253d406b61b42 (diff) | |
download | rails-c9eb5a083f0cf120fe7c3c1e19ead5cfc777b1fe.tar.gz rails-c9eb5a083f0cf120fe7c3c1e19ead5cfc777b1fe.tar.bz2 rails-c9eb5a083f0cf120fe7c3c1e19ead5cfc777b1fe.zip |
delegate AssociationProxy#to_param to the association target so that associated models can be used in routes. [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4398 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r-- | activerecord/lib/active_record/associations/association_proxy.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index ce0e154644..46804a3b93 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -4,6 +4,7 @@ module ActiveRecord attr_reader :reflection alias_method :proxy_respond_to?, :respond_to? alias_method :proxy_extend, :extend + delegate :to_param, :to => :proxy_target instance_methods.each { |m| undef_method m unless m =~ /(^__|^nil\?$|^send$|proxy_)/ } def initialize(owner, reflection) @@ -23,7 +24,7 @@ module ActiveRecord def proxy_target @target end - + def respond_to?(symbol, include_priv = false) proxy_respond_to?(symbol, include_priv) || (load_target && @target.respond_to?(symbol, include_priv)) end |