Never, never, use Rails attachments for anything.
I repeat: never use a Rails tool for anything.
They are dangerous, cumbersome and lead to the leak of your tests. They are not suitable for writing proper tests. At best, you get tests that look like they are spelled correctly, but have hidden dependencies. The Rails team got this feature 100% wrong, and I would like them to remove it from Rails so people don’t want to use it.
Instead, set factory_girl_rails and use factories to create your test records on request:
Factory :assembly, :parts => [Factory(:part, :name => 'first'), Factory(:part, :name => 'second')]
source
share