lib/superstore/belongs_to/reflection.rb in superstore-1.0.0 vs lib/superstore/belongs_to/reflection.rb in superstore-1.0.2
- old
+ new
@@ -9,10 +9,18 @@
def instance_variable_name
"@#{name}"
end
def foreign_key
- "#{name}_id"
+ options[:foreign_key] || "#{name}_id"
+ end
+
+ def primary_key
+ options[:primary_key] || "id"
+ end
+
+ def default_primary_key?
+ primary_key == "id"
end
def polymorphic_column
"#{name}_type"
end