Very strange behavior of script/generate ModelName field:type

After the typing the following in my terminal:

==================================
./script/generate model Paper user_id:integer title:string body:text
excerpt:text created_at:datetime updated_at:datetime

the following migration is created…

==================================
class CreatePapers < ActiveRecord::Migration
def self.up
create_table :papers do |t|
t.integer :user_id
t.string :title
t.text :body
t.text :excerpt
t.datetime :created_at
t.datetime :updated_at

  t.timestamps
end

end

def self.down
drop_table :papers
end
end

What happening here…?

Regards,

le colibri

Forgot to tell you that I’m on Rails 2.0.2

On Dec 30, 2007 3:51 PM, le colibri [email protected] wrote:

What happening here…?
Rails 2.0 puts timestamps in migrations by default, so you don’t need
to specify created_at and updated_at fields.
The rest of it looks just fine.

  • Martin

On Dec 30, 7:13 pm, “Martin S.” [email protected] wrote:

Rails 2.0 puts timestamps in migrations by default, so you don’t need
to specify created_at and updated_at fields.
The rest of it looks just fine.

  • Martin

Thanks, Matin. I just looked it up in the PeepCode Rails 2 PDF. I just
changed to Rails 2.0.2 and the syntax of the migration surprised me.

One more question: how does one create a migration from the command
line? E.g. what do I have to type instead of the old
‘user_id:integer’, which is done now with ‘t.reference :user’, or
‘t.belongs_to :user’

Thanks,

le colibri

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs