I got an if statement like this
if can?(:read, Category) || can?(:read, Category2)
If a user can read Category or Category2 an link gets shown.
But what if i have like 10 Categorys? There must be a shorter way instead of listing them. I need a bit help.
Assuming you have some list of objects:
You can get the result using
inject, like this:What this literally evaluates to is:
which of course is equivalent to: