July 20, 2012

Machinist 1.0: How to generate an object without saving it to the database

CAUTION It's specific machinist 1.0-maintenance.

Machinist is an alternative for Fixtures or FactoryGirl.


If you want to generate an object without saving it to the database, replace make with make_unsaved


So remember to use make_unsaved.


If you're interested, here is the source code.

Under latest version

Well if you're using latest machinist, which is 2.0 at this point, it's much simpler and cleaner.

make for generating but not saving an object, make! for saving it to database.

Share on Twitter Share the post
Qihuan Piao

Qihuan Piao

(aka kinopyo) is Chinese based in Tokyo. Software writer. He shares stories inspired him in this blog. His infamous line - "I feel calm when I kill those monsters, or people (in game)" shocks his friends deeply.

He also writes in Japanese and Chinese.