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.
264 265 266 267 268 269 270 |
# File 'lib/code_generator.rb', line 264 def initialize col, table, *actions @col = col @table = table if actions.count > 0 @action = actions[0] end end |
Instance Method Details
#gen ⇒ Object
272 273 274 275 276 277 278 |
# File 'lib/code_generator.rb', line 272 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 |