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.
51 52 53 |
# File 'lib/foreign_key_checker.rb', line 51 def scope @scope end |
Instance Method Details
#message ⇒ Object
52 53 54 |
# File 'lib/foreign_key_checker.rb', line 52 def "There is no foreign_key for relation #{human_relation}\n" end |
#migration ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/foreign_key_checker.rb', line 56 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
64 65 66 |
# File 'lib/foreign_key_checker.rb', line 64 def to_zombie ZombieResult.new(scope: scope, model: model, association: association) end |