Class: ActiveSchema::Associations::ByReverseForeignKey
- Inherits:
-
ByForeignKey
- Object
- ByForeignKey
- ActiveSchema::Associations::ByReverseForeignKey
- Defined in:
- lib/active_schema/associations/by_foreign_key.rb
Instance Method Summary collapse
Methods inherited from ByForeignKey
Methods included from Naming
Constructor Details
This class inherits a constructor from ActiveSchema::Associations::ByForeignKey
Instance Method Details
#generate ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/active_schema/associations/by_foreign_key.rb', line 35 def generate if @key_column_unique association @to_model, :has_one, name_for(@from_model), { :class_name => @from_model.name, :foreign_key => @key_column } else association @to_model, :has_many, plural_name_for(@from_model), { :class_name => @from_model.name, :foreign_key => @key_column } end end |