>
> associatedFields = @category.fields
> allFields = Field.all
>
> available = allFields - associatedFields
Field.all :conditions => ["id not in (?)", @category.fields.all.map(&:id)]
Field.where(["id not in (?)", @category.fields.all.map(&:id)]) if rails 3
Ivan Nastyukhin
dieinz...@me.com
Hi Sharagoz, thank you for your reply. However, I had already tried
array subtraction once, but with no success.
I tried for example:
associatedFields = @category.fields
allFields = Field.all
available = allFields - associatedFields
however it did not work.
When I try:
associatedFields.inspect
Fields.all gives you an array of all the fields in the database
@category.fields gives you an array of all the fields for the given
category (since you have the has_many :fields, :through
=> :categoryFields association)
How do you get the fields that are present in the first array but not
in the s
3 matches
Mail list logo