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? In this case, how can we read: t.string :name ? Thanks. -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Sep 21, 10:38 am, Abder-Rahman Ali <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Learn what a block is here http://www.robertsosinski.com/2008/12/21/understanding-ruby-blocks-procs-and-lambdas/ -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.