PDA

View Full Version : Creating tables with "variable" fields


kretch
February 26th, 2008, 01:32 AM
Hi All
I'm slowly ramping up on Ruby (Ex-PERL'y), and have the following question:
*) I'd like to create a table , but with column names which are not fixed. So instead of doing

def self.up
create_table mytable do |t|
t.column :field1, :string
t.column :field2, :string


I'd like to do

var1 = "field1"
var2 = "field2"
def self.up
create_table mytable do |t|
t.column $var1, :string
t.column $var2, :string


What is the correct syntax for doing that?

Best Regards
Kretch