icn icn - 2 months ago 7
Ruby Question

ruby on rails: How to create table for a new model

I use

rails generate model mynewmodel string:name string:description


to generate a new model. How do I deploy this new model to my develop databse ? I already have a bunch of databases in my sqlite db.

I have tried

rake db:migrate


it seemed having trouble to generate this new table in db.

update: added error message

== CreateMynewmodels: migrating ===============================================
-- create_table(:mynewmodels)
rake aborted!
An error has occurred, this and all later migrations canceled:

undefined method `name' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x3ad5c50>

Tasks: TOP => db:migrate


Thanks

Answer

The order of your fieldname:type combo is incorrect. Try

rails generate model mynewmodel name:string description:string