Class: ForeignKeyNode
Instance Method Summary collapse
- #gen ⇒ Object
-
#initialize(col, table, *actions) ⇒ ForeignKeyNode
constructor
A new instance of ForeignKeyNode.
Methods inherited from Node
Constructor Details
#initialize(col, table, *actions) ⇒ ForeignKeyNode
Returns a new instance of ForeignKeyNode.
276 277 278 279 280 281 282 |
# File 'lib/code_generator.rb', line 276 def initialize col, table, *actions @col = col @table = table if actions.count > 0 @action = actions[0] end end |
Instance Method Details
#gen ⇒ Object
284 285 286 287 288 289 290 |
# File 'lib/code_generator.rb', line 284 def gen col = @col.gen table_name = @table.gen class_name = @table.table_to_class key = @table.key_name "belongs_to :#{table_name}, foreign_key: '#{col}', class: '#{class_name}', primary_key: '#{key}'" end |