ruby on rails - Id column in schema.rb -


everytimes, have column event object (event-calendar gem) in schema.rb file

t.integer  "id", :null => false 

so of course, every time want create event have error "null value in column "id" violates not-null constraint" because of this. tried solution activerecord::statementinvalid: pg::error: error: null value in column "id" violates not-null constraint appears everytimes !!! know why column appears here, don't understand...

any idea ?

when created events model, sounds added id field. isn't necessary rails automatically creates field. event model in schema should like:

create_table "events", :force => true |t|   t.string   "name"   t.datetime "created_at",  :null => false   t.datetime "updated_at",  :null => false end 

i rollback migration, assuming recent migration:

rake db:rollback 

then update migration file , remove id create_table block:

class createevents < activerecord::migration   def change     create_table :events |t|       t.string :name        t.timestamps     end    end end 

then rerun migration.


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -