Reputation: 7001
If in a form I have resources loaded like so:
def custom_articles
@user.custom_articles + @user.edited_articles || []
end
And they're outputted into a checkbox list, how can I differentiate between what is an EditedArticle
and what is a CustomArticle
? custom_articles
are added to a collection of Component
s too.
Upvotes: 0
Views: 15
Reputation: 3881
If you need to keep the context, then keep the context! Instead of passing back an array, why can't you pass back a hash that won't step on the type?
def custom_articles
{custom: @user.custom_articles, edited: @user.edited_articles}
end
edited:
custom_articles[:edited]
custom:
custom_articles[:custom]
all articles:
custom_articles.values.flatten
Upvotes: 2