Return only some resources from 2 tables


I'm having trouble selecting only some specific resources from 2 tables. That's my code: categories = %w{cat1 cat2 cat3} categories.each { |category|   cat = CharacterAttributeCategory.find_by_name category   @character_attribute_types += CharacterAttributeType.find_all_by_character_attribute_category_id }

I tried << before but that doesn't work as well. I get following error: NoMethodError in CharactersController#new

You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.+

Any hints?

Do you mean this?

@character_attribute_types = @character_attribute_types << CharacterAttributeType.find_all_by_character_attribute_category_id