Newbie - How Do I Create a new Table


#1

Ok I have been running around the web for the last couple of hours
and can not for the life of me figure out how to create a new table
using the create_table method found in the docs here:

http://api.rubyonrails.com/classes/ActiveRecord/ConnectionAdapters/
SchemaStatements.html#M000507

Basically I have set up a DB as well as a scaffold and made some
changes. When i create a new record i want to also create a new table
that is associated with that record to hold some other data. I have
tried both ways in the api doc from my controller as well as the
model and still can not get it to actually create a table. I receive
various errors telling me the method for create_table can not be
found. The code I am trying to run right now is generic as I just
want a table created it is:

create_table(:suppliers)
add_column(:suppliers, :name, :string, {:limit => 60})

Can some one please point me at an example or a tutorial?

Thanks in advance.

Andrew


#2

Seems like you’re using the wrong syntax. Try this article… I think
it’ll help demystify the process for you.

http://glu.ttono.us/articles/2005/10/27/the-joy-of-migrations

Amy


Ruby on Rails, Design, Writing…
http://www.slash7.com/