From f29ae1253538b1182c2cabfcfbcc8f8b70bab575 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Sun, 7 Oct 2007 02:13:51 +0000 Subject: Add Base#to_param to Active Resource that quacks like ActiveRecord. Closes #9557 [bradediger] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7764 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activeresource/lib/active_resource/base.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'activeresource/lib/active_resource') diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb index 9fb347d2c3..b1a79731b9 100644 --- a/activeresource/lib/active_resource/base.rb +++ b/activeresource/lib/active_resource/base.rb @@ -550,6 +550,11 @@ module ActiveResource attributes[self.class.primary_key] = id end + # Allows ActiveResource objects to be used as parameters in ActionPack URL generation. + def to_param + id && id.to_s + end + # Test for equality. Resource are equal if and only if +other+ is the same object or # is an instance of the same class, is not +new?+, and has the same +id+. # -- cgit v1.2.3