Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 590
icn Avatar asked Nov 20 '12 22:11

icn


1 Answers

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

rails generate model mynewmodel name:string description:string
like image 155
4-8-15-16-23-42 Avatar answered Oct 05 '22 08:10

4-8-15-16-23-42