Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Active Resource associations, refactoring remove some duplication
  • Loading branch information
gramos committed Oct 6, 2010
1 parent 25207f8 commit 0c05f0e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions activeresource/lib/active_resource/associations.rb
Expand Up @@ -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

Expand Down

0 comments on commit 0c05f0e

Please sign in to comment.