Re: How ActiveRecords create tables

Cris Shupp
Fri, 25 Sep 2009 00:45:50 -0000

Oh and this does work, not around the block as you said:

  def self.up
    create_table (:people) { |t|
      t.string :name, :type, :email, :camera
      t.timestamps
    }
  end

Thanks again!

Cris Shupp wrote:
> Marnen,
>
> Thanks!  You answered my questions perfectly!!!
>
> Thanks,
>
> Cris
>
> Marnen Laibow-Koser wrote:
>> Marnen Laibow-Koser wrote:
>>> Cris Shupp wrote:
>> [...]
>>>> How come I cannot write the code as follows (Aptana will not
compile
>>>> it)?
>>>>   def self.up
>>>>     create_table (:people,{|t|
>>>>       t.string :name, :type, :email, :camera
>>>>       t.timestamps
>>>>     })
>>>>   end
>>>
>>> Because you''ve got your syntax wrong.  The braces
aren''t correct In this
>>> context (this isn''t JavaScript!) and parens don''t
go around blocks
>>> passed to functions.
>> [...]
>>
>> On second thought, the braces are probably OK (although it''s
more common
>> to use do...end for multiline blocks and braces for single-line ones).
>> The bigger problem is the parentheses.  If you''re going to use
them,
>> then the closing parenthesis goes *before* the beginning of the block.
>>
>> Best,
>> --
>> Marnen Laibow-Koser
>> http://www.marnen.org
>> marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org