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

Prolog - Listing -

orchardcms - change base url in local copy in Orchard CMS -

linear regression - Trying to get confidence/prediction intervals with `predict.lm` in R, but I keep getting an error regarding my dichotomous variable -