Allow to set key for associations through options

This commit is contained in:
Santiago Pastorino
2013-08-26 15:32:02 -03:00
parent 48590a2e37
commit 280fd65db8
3 changed files with 18 additions and 2 deletions

View File

@@ -45,7 +45,7 @@ module ActiveModel
class HasOne < Association
def key
"#{name}_id"
@options[:key] || "#{name}_id"
end
def embedded_key
@@ -55,7 +55,7 @@ module ActiveModel
class HasMany < Association
def key
"#{name.singularize}_ids"
@options[:key] || "#{name.singularize}_ids"
end
def embedded_key