Class: ForeignKeyChecker::ForeignKeyResult
- Defined in:
- lib/foreign_key_checker.rb
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Attributes inherited from Result
Instance Method Summary collapse
Methods inherited from Result
#from_column, #from_table, #human_relation, #initialize, #inspect, #nullable?, #to_column, #to_table
Constructor Details
This class inherits a constructor from ForeignKeyChecker::Result
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
46 47 48 |
# File 'lib/foreign_key_checker.rb', line 46 def scope @scope end |
Instance Method Details
#message ⇒ Object
47 48 49 |
# File 'lib/foreign_key_checker.rb', line 47 def "There is no foreign_key for relation #{human_relation}\n" end |
#migration ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/foreign_key_checker.rb', line 51 def migration "add_foreign_key :#{from_table}, :#{to_table}#{ ", column: :#{from_column}" if from_column.to_s != "#{to_table.singularize}_id" }#{ ", primary_key: :#{to_column}" if to_column.to_s != 'id' }" end |
#to_zombie ⇒ Object
59 60 61 |
# File 'lib/foreign_key_checker.rb', line 59 def to_zombie ZombieResult.new(scope: scope, model: model, association: association) end |