On Sep 21, 10:38 am, Abder-Rahman Ali <[email protected]> wrote:
> At the following:http://guides.rubyonrails.org/migrations.html
>
> You can find:
>
> def self.up
> create_table :products do |t|
> t.string :name
> t.text :description
> t.timestamps
> end
>
> Regarding this line:
>
> create_table :products do |t|
>
> What is passed to the block variable "t", is it :products?

The create_table function returns a new instance of the
TableDefinition class. The |t| assigns it to the t variable.

>
> In this case, how can we read:
>
> t.string :name
>
> ?
>
> Thanks.

This is calling the string() method on the instance of
TableDefinition.

Basically it would be the same as doing this:

t = TableDefinition.new()
t.string(:name)

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to