On Dec 19, 11:03 am, daze <[email protected]> wrote:
> Figured it out. Here's the summary:
>
> If you have a sequence called :xyz and you are calling it in a
> factory, YOU NEED TO HAVE BRACKETS around the Factory.next(:xyz)
> call. In my case:
>
> # Factories
> Factory.define :article do |t|
> t.association :section # 'belongs to a section'
> t.title {|x| "Article#{Factory.next(:count)}" }
> (...)
> end
As a note, in the case where you just want a number in a string I
prefer this syntax:
Factory.define :article do |t|
t.association :section
t.sequence(:title) {|n| "Article#{n}"}
end
That way you don't have a sequence who's only job is to replicate this
functionality; save those sequences for something that is more complex
that you want to reuse and count.
\Peter
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.