showcased_project_entries =
@project.contest_entries.where("view_in_showcase = ?", true)
entries = showcased_project_entries ? showcased_project_entries.count : 1
or
entries =
@project.contest_entries.where("view_in_showcase = ?", true).try(:count) || 1
Although, I must admit I am not sure under which circumstances where returns a falsy value.
EDIT: As noted in the comments, the else clause indeed never triggers, so your code probably does not do what you want. See Andy H's solution for the case where you want to have entries be 1 when you find no results, if that is what you meant.
elseclause in Ruby.entriesto be anything other than 0 or the count ofcontest_entries. Theentries = 1branch will never execute. This makes the code very misleading; I'd consider fixing it.