From 0c05f0e4d57485531e5d39d51ca0a00c5c125d09 Mon Sep 17 00:00:00 2001 From: Gaston Ramos Date: Wed, 29 Sep 2010 17:02:19 -0300 Subject: [PATCH] - Active Resource associations, refactoring remove some duplication --- activeresource/lib/active_resource/associations.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/activeresource/lib/active_resource/associations.rb b/activeresource/lib/active_resource/associations.rb index 93235cf775167..cf3b8133e3c31 100644 --- a/activeresource/lib/active_resource/associations.rb +++ b/activeresource/lib/active_resource/associations.rb @@ -24,12 +24,13 @@ def options(association, resource) case association when :has_many - o[:association_col] = "#{o[:host_klass].to_s.singularize.underscore}_id".to_sym + o[:association_col] = o[:host_klass].to_s.singularize when :belongs_to - o[:association_col] = "#{o[:klass].underscore}_id".to_sym + o[:association_col] = o[:klass] when :has_one - o[:association_col] = "#{o[:host_klass].to_s.underscore}_id".to_sym + o[:association_col] = o[:host_klass].to_s end + o[:association_col] = "#{o[:association_col].underscore}_id".to_sym o end