[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[Rails] Where is create_table method defined?

grz01

2/9/2008 3:49:00 AM

Hi

When scaffolding a model with Rails, you will get a migration file,
say 001_create_items.rb
that looks something like this:

class CreateItems < ActiveRecord::Migration
def self.up
create_table :items do |t|
...
end
end

def self.down
drop_table :items
end
end

My question is: Where is this method 'create_table' defined in Rails?
I was expecting to find it in the superclass ActiveRecord::Migration
which I think is defined in file .../lib/active_record/migration.rb
But I cannot find it there.

Anyone has a clue?

TIA
------------- grz01
1 Answer

Phlip

2/9/2008 4:00:00 AM

0

grz01@spray.se wrote:

> create_table :items do |t|

> My question is: Where is this method 'create_table' defined in Rails?

Part of learning Rails is learning to find its source code,
documentation, and forums.

The best forum is Google's Ruby-on-Rails Talk forum. Google for that.

Next, learn to use www.google.com/codesearch to go directly to source,
formatted for programmers. Search like this:

def\ self\.create_table

Google codesearch supports regular expressions, so \ declares the space
is important, and likewise the \. dot.

Your command line might support this:

$ ri create_table
$ ri ActiveRecord::ConnectionAdapters::SchemaStatements#create_table

The first one told me where to look for create_table, and the second told
me much more than I ever wanted to know about it!

Finally, learn to use grep in your Rails source folders. Rails is well
documented, including in its own source, so you'd better get familiar
with reading it!

Post any future Rails questions to that Google Group, to avoid offending
the 0.02% of this forum who was here before Rails. (-:

--
Phlip
watch this space for more assert{ 2.0 } goodness!