Re: [Rails] Re: Has many_through, how to show only unassociated fields for a category?

2010-06-03 Thread Ivan Nastyukhin
> > 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

[Rails] Re: Has many_through, how to show only unassociated fields for a category?

2010-06-03 Thread Samuel
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

[Rails] Re: Has many_through, how to show only unassociated fields for a category?

2010-06-03 Thread Sharagoz
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