私のモデルには、次のようないくつかの関連付けがあります。
has_many :posts
has_many :comments, :through => :posts
belongs_to :user
パラメータで指定されたように、関連するオブジェクトを収集するメソッドもあります。
def selected_associations(*associations)
associations.collect{|association| self.association}
end
問題は、どのように渡すの*associations
ですか? 私はシンボルの配列でそうしようとしました:
self.selected_associations([:posts, :comments])
しかし、それはうまくいきません。それらを文字列として渡すこともありません。おそらく私はこれに正しい方法でアプローチしていませんか?