Creating tables with "variable" field names

Y

Yaron Kretchmer

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

<Code>
def self.up
create_table mytable do |t|
t.column :field1, :string
t.column :field2, :stringI'd like to do
</Code>

I'd like to do

<Code>
var1 = "field1"
var2 = "field2"
def self.up
create_table mytable do |t|
t.column $var1, :string
t.column $var2, :stringWhat is the correct syntax for doing that?
</Code>
Best Regards
Kretch
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top