Fixture プラグインを使用して Grails アプリケーションにデータをロードしようとしています。
class Author {
String name
}
class Book {
String title
hasMany = [authors:Author]
}
Author を別のファイルにロードし、それを Book に含めます。
//author fixture
fixture {
author1(Author) {
name = 'Ken Follett'
}
author2(Author) {
name = 'Martin Fowler'
}
}
//book fixture
fixture {
include 'author'
"book"(Book) {
title = 'Your favorite book'
authors = [author1, author2]
}
}
これはすべてうまくいきます。私ができないことは、 [author1, author2] を置き換えて、動的に (そしてランダムに) 作成者を割り当てることです。何かのようなもの:
def dynamicallyBuiltAuthorList = "author1, author2, author100"
authors = ["${dynamicallyBuiltAuthorList}"]
これまでに試したことのほとんどすべてで、一致するエディターまたは変換戦略が見つからないというエラーが発生しました。
事前に感謝します Grails 達人!