11155
(-- --)
1
At the following: Active Record Migrations — Ruby on Rails Guides
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?
In this case, how can we read:
t.string :name
?
Thanks.
At the following:Active Record Migrations — Ruby on Rails Guides
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)