Reputation: 980
My question is simple... or so it seems. If @set.cards
retrieves "id", "front", "back", "created_at" (etc.). How do I get just an array of the id's? [1,2,3,4,5...etc]
?
Upvotes: 1
Views: 1609
Reputation: 64363
Rails provides a standard method for this:
@set.card_ids
Reference: The has_many
documentation. Look at the 5th method from the top, i.e. collection_singular_ids
.
Upvotes: 5