ruby - Rails fixtures — Incrementing an ID attribute automatically? -


i have fixtures file id's this:

post_one:   id: 1   attr2: 'some_value'  post_two:   id: 2   attr3: 'some_other_value' 

and on.

is there way not have type in id's each record, , have incremented automatically?

if don't specify id, hash label , use id. benefits of not specifying id:

  • stable, autogenerated ids
  • label references associations (belongs_to, has_one, has_many)
  • habtm associations inline lists
  • autofilled timestamp columns
  • fixture label interpolation
  • support yaml defaults

see page in documentation more info on fixtures: http://api.rubyonrails.org/classes/activerecord/fixtureset.html


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -