How can I make better use of abstraction in rails fixtures? I don't like constantly repeating myself and having to remember the primary key value when adding foriegn key values ... etc
People succeed in answering Rich Collins's questions 37% of the time (32 successes in 86 attempts).
Answers by: Mark Imbriaco | Fear of Fish | Adam Thorsen
There's a fairly ugly way to accomplish this with the existing fixtures functionality:
posts.yml:
<% rich = User.find_by_name('Rich') %>
fist_post_by_rich:
id: 1
user_id: <%= rich.id %>
Thanks should have thought of that one. It is a bit ugly as you have to do it for each fixture file but still better than the way I have been. Perhaps I should do some fixtures plugin in my "spare time"