Permalink
Browse files

- Active Resource associations, refactoring remove some duplication

  • Loading branch information...
1 parent 25207f8 commit 0c05f0e4d57485531e5d39d51ca0a00c5c125d09 @gramos committed Sep 29, 2010
Showing with 4 additions and 3 deletions.
  1. +4 −3 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

0 comments on commit 0c05f0e

Please sign in to comment.